Commit 65bacd90 authored by sully.khalifa's avatar sully.khalifa

Final commit

parent 6b569c97
......@@ -78,6 +78,10 @@ class EventView:
name = input("Enter event name: ") # Prompt the user for input and assign it to the variable "name"
organizer = input("Enter organizer name: ") # Prompt the user for input and assign it to the variable "organizer"
description = input("Enter event description: ") # Prompt the user for input and assign it to the variable "description"
if name.strip() == "" or organizer.strip() == "" or description.strip() == "":
print("Please provide all values. Try Again")
else:
event = self.event_factory.create_event(name, organizer, description) # Create an Event object using the "event_factory" instance variable and the input from the user
self.events.append(event) # Add the newly created event object to the list stored in the "events" instance variable
print(f"Event {name} created successfully!") # Print a message confirming the event has been created
......@@ -86,8 +90,12 @@ class EventView:
event = next((x for x in self.events if x.name == event_name), None) # Iterate through the list stored in the instance variable "events" and return the first event object whose "name" attribute matches the parameter "event_name" or return None
if event:
name = input("\nEnter Plus one invitee name: ") # Prompt the user for input and assign it to the variable "name"
rsvp = input("Has Plus one invitee RSVPd? (y/n)").lower() == "y" # Prompt the user for input, convert it to lowercase, and check if it is equal to "y" and assign the boolean value to "rsvp"
rsvp = input("Has Plus one invitee RSVPd? (y/n) *Pressing enter to skips will be considered <No>").lower() == "y" # Prompt the user for input, convert it to lowercase, and check if it is equal to "y" and assign the boolean value to "rsvp"
dietary_req = input("Enter invitee dietary requirements: ") # Prompt the user for input and assign it to the variable "dietary_req"
if name.strip() == "" or dietary_req.strip() == "":
print("Please provide all values. Try Again")
else:
invitee = self.event_factory.create_invitee(name, rsvp, False, dietary_req) # Create an Invitee object using the "event_factory" instance variable and the input from the user, with the plus_one attribute set to true
event.add_invitee(invitee) # Add the newly created invitee object to the list of invitees of the event
print(f"Invitee {name} added to event {event_name} as plus One") # Print a message confirming the invitee has been added as plus one
......@@ -96,12 +104,18 @@ class EventView:
def add_invitee(self):
event_name = input("Enter event name: ") # Prompt the user for input and assign it to the variable "event_name"
if event_name.strip() == "" :
print("Please provide a proper event name")
else:
event = next((x for x in self.events if x.name == event_name), None) # Iterate through the list stored in the instance variable "events" and return the first event object whose "name" attribute matches the input event_name or return None
if event:
name = input("Enter invitee name: ") # Prompt the user for input and assign it to the variable "name"
rsvp = input("Has invitee RSVPd? (y/n)").lower() == "y" # Prompt the user for input, convert it to lowercase, and check if it is equal to "y" and assign the boolean value to "rsvp"
rsvp = input("Has invitee RSVPd? (y/n) *Pressing enter to skip will be considered <No>").lower() == "y" # Prompt the user for input, convert it to lowercase, and check if it is equal to "y" and assign the boolean value to "rsvp"
dietary_req = input("Enter invitee dietary requirements: ") # Prompt the user for input and assign it to the variable "dietary_req"
plus_one = input("Is invitee bringing a plus one? (y/n)").lower() == "y" # Prompt the user for input, convert it to lowercase, and check if it is equal to "y" and assign the boolean value to "plus_one"
plus_one = input("Is invitee bringing a plus one? (y/n) *Pressing enter to skips will be considered <No> ").lower() == "y" # Prompt the user for input, convert it to lowercase, and check if it is equal to "y" and assign the boolean value to "plus_one"
if name.strip() == "" or dietary_req.strip() == "":
print("Please provide all values")
else:
if plus_one:
self.addPlusOne(event_name) # If the invitee is bringing a plus one, call the addPlusOne method and pass the event_name
invitee = self.event_factory.create_invitee(name, rsvp, plus_one, dietary_req) # Create an Invitee object using the "event_factory" instance variable and the input from the user
......@@ -112,6 +126,9 @@ class EventView:
def view_invitees(self):
event_name = input("Enter event name: ") # Prompt the user for input and assign it to the variable "event_name"
if event_name.strip() == "" :
print("Please provide a proper event name")
else:
event = next((x for x in self.events if x.name == event_name), None) # Iterate through the list stored in the instance variable "events" and return the first event object whose "name" attribute matches the input event_name or return None
if event:
event.view_invitees() # call the view_invitees method on the event object
......@@ -120,9 +137,15 @@ class EventView:
def add_menu_item(self):
event_name = input("Enter event name: ") # Prompt the user for input and assign it to the variable "event_name"
if event_name.strip() == "" :
print("Please provide a proper event name")
else:
event = next((x for x in self.events if x.name == event_name), None)
if event:
meal = input("Enter meal name: ") # Prompt the user for input and assign it to the variable "meal"
if meal.strip() == "":
print("Please provide a proper meal name")
else:
event.menu.add_item(meal)
print(f"Meal {meal} added to event {event_name}") # Print a message confirming the meal has been added
else:
......@@ -130,6 +153,9 @@ class EventView:
def view_menu(self):
event_name = input("Enter event name: ") # Prompt the user for input and assign it to the variable "event_name"
if event_name.strip() == "" :
print("Please provide a proper event name")
else:
event = next((x for x in self.events if x.name == event_name), None) #needs commenting
if event:
event.menu.view_menu()
......@@ -138,6 +164,9 @@ class EventView:
def search_invitee(self):
invitee_name = input("Enter invitee name: ") # Prompt the user for input and assign it to the variable "invitee_name"
if invitee_name.strip() == "":
print("Please provide a proper name")
else:
for event in self.events: # Iterate through the list stored in the instance variable "events"
invitee = next((x for x in event.invitees if x.name == invitee_name), None) # Iterate through the list of invitees of the event and return the first invitee object whose "name" attribute matches the input invitee_name or return None
if invitee:
......@@ -154,32 +183,41 @@ class EventView:
def select_menu(self):
event_name = input("Enter event name: ") # Prompt the user for input and assign it to the variable "event_name"
if event_name.strip() == "":
print("Please provide a event name")
else:
event = next((x for x in self.events if x.name == event_name), None)
if event:
invitee_name = input("Enter your name : ") #If the event exists, prompt the user for input and assign it to the variable "invitee_name"
if invitee_name.strip() == "":
print("Provide a proper name")
else:
for event in self.events:
invitee = next((x for x in event.invitees if x.name == invitee_name), None)
if invitee: #If the event exists in the list of events and if the list of invitee contains the variable invitee_name, start the while loop.
while True : #The while loop will not end unless something returns False
if len(event.menu.items) > 0 : #If the length of an item list is more than 0, continue.
meal_name = input("What are you having? : ") #Prompt the user for input and assign it to the variable meal_name
if meal_name in event.menu.items: #If the given meal_name from the invitee is in the menu, order is successful and the invitee_name and the ordered meal get stored.
if meal_name in event.menu.items and meal_name.strip() != "": #If the given meal_name from the invitee is in the menu, order is successful and the invitee_name and the ordered meal get stored.
event.track_invitee_meals[invitee_name] = meal_name
print("Ordered Successfully")
return False
else:
print(f"{meal_name} not found. try again.") # Print an error message if the meal name is not found
print(f"{meal_name} not found. try again.")
return True
else:
print("Add menu before selecting menu.") # Print a prompt message to add menu item before selcting a menu
print("Add menu before selecting menu.")
return False
else :
print(f"{invitee_name} is not in the invitee_list") # Print an error message if the invitee is not in the invitee list
print(f"{invitee_name} is not in the invitee_list")
else:
print(f"Event {event_name} not found.") # Print an error message if the event is not found
print(f"Event {event_name} not found.")
def track_meals(self):
event_name = input("Enter event name: ") #Prompt the user for input and assign it to the variable event_name
if event_name.strip() == "":
print("Please provide a event name")
else:
event = next((x for x in self.events if x.name == event_name), None)
if event: #If the event exists, Go through the dictionary of track_invitee_meals using for loop.
for invitee, meal in event.track_invitee_meals.items():
......@@ -228,6 +266,8 @@ def main():
elif choice == "10":
# Exit the loop if the user chooses the "Exit" option
break
else:
print("Pick a number from above !!!!")
if __name__ == "__main__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment