You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feat: Added add_itinerary functionality to main program (main.py) and function handler (manage_itineraries.py). Also added requirements.txt for pip install.
attractions=input("") # dictionary - add loop here
26
-
ifattractions=="DONE":
27
-
attractions_list_done=True
20
+
flights= {}
21
+
attractions= {}
22
+
23
+
print("\nNow it is time to add flights!")
24
+
user_flight_choice=input("If you want to skip this step, type SKIP and press 'Enter'. Otherwise, press 'Enter'. ")
25
+
flights_list_done=False
26
+
27
+
ifuser_flight_choice=="SKIP":
28
+
flights= {}
29
+
else:
30
+
whilenotflights_list_done:
31
+
flight_details= {}
32
+
33
+
departure_airport=input("Name of the airport you will depart from: ")
34
+
departure_date=input("Date & time of flight departure (Format: DD-MM-YYYY HH:MM): ")
35
+
arrival_airport=input("Name of the airport you will arrive at: ")
36
+
arrival_date=input("Date & time of flight arrival (Format: DD-MM-YYYY HH:MM): ")
37
+
flight_name=f"{departure_airport} to {arrival_airport}"
38
+
39
+
flight_details.update({
40
+
"departure airport": departure_airport,
41
+
"departure date": departure_date,
42
+
"arrival airport": arrival_airport,
43
+
"arrival date": arrival_date
44
+
})
45
+
flights[flight_name] =flight_details
46
+
47
+
add_another_flight=input("Would you like to add another flight? Type Y (yes) or N (no): ")
48
+
whileTrue:
49
+
ifadd_another_flight=="Y":
50
+
flights_list_done=True
51
+
break
52
+
elifadd_another_flight=="N":
53
+
flights_list_done=False
54
+
break
55
+
else:
56
+
print("Invalid answer: Please type Y or N only.")
57
+
58
+
print("\nFinally: ATTRACTIONS!")
59
+
user_attractions_choice=input("If you want to skip this step, type SKIP and press 'Enter'. Otherwise, press 'Enter'. ")
60
+
attractions_list_done=False
61
+
62
+
ifuser_attractions_choice=="SKIP":
63
+
attractions= {}
64
+
else:
65
+
whilenotattractions_list_done:
66
+
attraction_details= {}
67
+
68
+
attraction_name=input("Name of attraction: ")
69
+
attraction_address=input("Address of attraction: ")
70
+
attraction_summary=input("Short description of attraction: ")
71
+
attraction_type=input("(Optional) Provide some tags that categorise what kind of activity this involves.\nExample of format required: hike, exciting, views\n")
72
+
attraction_tags=attraction_type.split(", ")
73
+
74
+
attraction_details.update({
75
+
"address": attraction_address,
76
+
"summary": attraction_summary,
77
+
"tag(s)": attraction_tags
78
+
})
79
+
attractions[attraction_name] =attraction_details
80
+
81
+
add_another_attraction=input("Would you like to add another attraction? Type Y or N:")
itinerary_list (list): The list of existing Itinerary objects.
16
+
location (str): The main city/country the holiday takes place.
17
+
summary (str, optional): A brief summary of the travel plan.
18
+
start_date (str): The date the holiday begins in 'DD-MM-YYYY' format.
19
+
end_date (str): The date the holiday ends in 'DD-MM-YYYY' format.
20
+
flights (nested dict): A nested dictionary type. Flight name (before-after location format, e.g. Perth-Sydney) is tied to a date in 'DD-MM-YYYY' format.
21
+
attractions (nested dict): Dictionary of attractions. Each dictionary key (name of attraction) contains a short description of the attraction (object).
22
+
23
+
Returns:
24
+
bool: True if Itinerary is added without issue, otherwise False.
25
+
26
+
Raises:
27
+
ValueError: If the start or end date is not in the correct format.
28
+
29
+
Side Effects:
30
+
- Saves the updated itinerary list to a file using `update_itinerary`.
31
+
"""
32
+
# Prevent duplicate itineraries
33
+
ifany(trip.name==namefortripinitinerary_list):
34
+
print("Error: A trip with this name already exists!")
0 commit comments