import time def int_checker(question, low, high): while True: error = f"Enter a number between {low} and {high} or done" to_check = input(question).lower() if to_check == "done": return "done" try: user_response = int(to_check) if low <= user_response <= high: return user_response else: print(error) except ValueError: print(error) def string_checker(question, valid_ans): shortcuts = {'p': 'pick up', 'd': 'delivery'} while True: user_response = input(question).strip().lower() if user_response in shortcuts: return shortcuts[user_response] elif user_response in valid_ans: return user_response print(f"Enter a valid response from {valid_ans + list(shortcuts.keys())}") def cash_credit(question): valid_responses = {"cash": "cash", "ca": "cash", "credit": "credit", "cr": "credit"} while True: response = input(question).lower() if response in valid_responses: return valid_responses[response] print("Please choose a valid payment method.") def history(): print(''' In the heart of New Zealand's bustling food scene, nestled among the vibrant streets of Mount Maunganui, lies Whanau Pizzeria—a cornerstone of culinary delight since its inception in the early 1990s. Founded by Italian immigrants Luca and Sofia Di Napoli, who brought with them generations-old recipes and a passion for authentic Italian cuisine, Whanau Pizzeria quickly became a beloved local institution. ''') def display_menu(): print("<--------------- Menu --------------->") print( "Pizza Sauces:" "\n1- Cheese sauce: $1.50" "\n2- Pesto sauce: $1.50" "\n3- Marinara: Free" "\n4- Barbeque: $1.50\n" "\n<------------------------------------>" "\nToppings:" "\n5- Mozzarella Cheese: $1.50" "\n6- Ground beef: $3.50" "\n7- Smoked ham: $3.50" "\n8- Pepperoni: $3.50" "\n9- Onion: $2.00" "\n10- Olives: $2.00" "\n11- Spinach: $2.00" "\n12- Spring Onion: $1.00\n" "\n<------------------------------------>" "\nGourmet toppings:" "\n13- Premium Italian Sausage: $5.50" "\n14- Smoked Bacon: $3.50" "\n15- Slow cooked lamb: $5.50" "\n16- Camembert cheese: $3.50" "\n17- Capsicum: $4.50\n" "\n<------------------------------------>" "\n Small | Medium | Large |" "\n $5 | $7 | $9 |" "\n ------|--------|-------|" ) print( "Note: Marinara sauce is free. Other sauces are $1.50 extra. The pizza will automatically have Marinara sauce unless another sauce is added.\n") def get_size_cost(size_option, size_prices): size = string_checker("Choose a size (small, medium, large): ", size_option) return size, size_prices[size] def get_toppings(toppings_menu): toppings = [] total_topping_cost = 0.0 while True: topping = int_checker("Choose a topping (1-17) or type 'done' to finish: ", 1, 17) print(f"chosen: {topping}") if topping == 'done': break toppings.append(topping) topping_cost = toppings_menu[topping]['cost'] total_topping_cost += topping_cost print(f"{toppings_menu[topping]['name']} added. Total topping cost: ${total_topping_cost:.2f}") return toppings, total_topping_cost def order_one_pizza(pizza_number, size_option, size_prices, toppings_menu): display_menu() print(f"\nOrdering pizza {pizza_number}...") # Get size size_result = get_size_cost(size_option, size_prices) size = size_result[0] size_cost = size_result[1] # Get toppings toppings_result = get_toppings(toppings_menu) toppings = toppings_result[0] topping_cost = toppings_result[1] total_cost = size_cost + topping_cost return size, size_cost, toppings, total_cost def order_multiple_pizzas(size_option, size_prices, toppings_menu): total_cost = 0 pizza_details = [] pizza_number = 1 while True: # Order a pizza order_result = order_one_pizza(pizza_number, size_option, size_prices, toppings_menu) size = order_result[0] size_cost = order_result[1] toppings = order_result[2] pizza_total_cost = order_result[3] pizza_summary = f"Pizza {pizza_number} - Size: {size.capitalize()} (${size_cost})" if toppings: pizza_summary += "\n Toppings:" for topping in toppings: pizza_summary += f"\n - {toppings_menu[topping]['name']}: ${toppings_menu[topping]['cost']}" pizza_summary += f"\n Total for this pizza: ${pizza_total_cost:.2f}" print(pizza_summary) pizza_details.append(pizza_summary) total_cost += pizza_total_cost order_more = string_checker("Would you like to order another pizza? (yes or no): ", ["yes", "no"]) if order_more == "no": break pizza_number += 1 return pizza_details, total_cost def not_blank(question): error = "Enter a name" while True: user_name = input(question) if user_name != '': return user_name else: print(error) def order_pizza(): # Display welcome and history print("<--- Welcome to the Whanau Pizzeria --->") print( "In this order system, you will create a custom pizza. Note: All pizza bases are plain. (please use yes or no response) 🍕") want_history = string_checker("\nWould you like to learn about the history of Whanau Pizzeria: ", ["yes", "no"]) if want_history == "yes": history() want_order = string_checker("Would you like to order delivery or pick up: ", ["delivery", "pick up"]) if want_order == "delivery": print("\nThere will be a $10 surcharge for delivery") print() name = not_blank("Enter your name: ") # Ask for address print() want_menu = not_blank("Enter your address: ") else: print("Our address is:\n565 Maunganui Road, Mount Maunganui 3116.") print("See you soon!\n") want_instructions = string_checker("Do you want to read the instructions? (yes or no): ", ["yes", "no"]) if want_instructions == "yes": print("\nYou will see a menu with options for pizza sauces, toppings, and gourmet toppings." "\nSelect toppings by entering the corresponding number. Type 'done' when you've finished selecting toppings.\n") else: print("No instructions will be displayed.\n") size_option = ["small", "medium", "large"] size_prices = {"small": 5, "medium": 7, "large": 9} toppings_menu = { 1: {"name": "Cheese sauce", "cost": 1.50}, 2: {"name": "Pesto sauce", "cost": 1.50}, 3: {"name": "Marinara", "cost": 0.0}, 4: {"name": "Barbeque", "cost": 1.50}, 5: {"name": "Mozzarella Cheese", "cost": 1.50}, 6: {"name": "Ground beef", "cost": 3.50}, 7: {"name": "Smoked ham", "cost": 3.50}, 8: {"name": "Pepperoni", "cost": 3.50}, 9: {"name": "Onion", "cost": 2.00}, 10: {"name": "Olives", "cost": 2.00}, 11: {"name": "Spinach", "cost": 2.00}, 12: {"name": "Spring Onion", "cost": 1.00}, 13: {"name": "Premium Italian Sausage", "cost": 5.50}, 14: {"name": "Smoked Bacon", "cost": 3.50}, 15: {"name": "Slow cooked lamb", "cost": 5.50}, 16: {"name": "Camembert cheese", "cost": 3.50}, 17: {"name": "Capsicum", "cost": 4.50} } pizza_details, total_cost = order_multiple_pizzas(size_option, size_prices, toppings_menu) print("\n<--- Order Summary --->") for detail in pizza_details: print(detail) print(f"\nTotal cost: ${total_cost:.2f}") confirm_order = string_checker("\nWould you like to confirm your order? (yes or no): ", ["yes", "no"]) if confirm_order == "no": print("\nOrder canceled.") return payment_method = cash_credit("\nChoose a payment method (cash or credit): ") print(f"You have chosen to pay with {payment_method}.") rating = input("Please rate your overall experience at Whanau Pizzeria (1-5) stars: ") while not rating.isdigit() or not 1 <= int(rating) <= 5: print("Invalid rating. Please enter a number between 1 and 5 stars.") rating = input("Enter your rating: ") rating = int(rating) comments = input("\nWould you like to leave any comments about your experience? (or press Enter to skip): ") print("\nThank you for your review!") print(f"You rated Whanau Pizzeria {rating}/5 stars. 🍕🎉") if comments: print(f"Comments: {comments}") print("\nYour order has been confirmed!") # Function to start the ordering process order_pizza() # Time wait time.sleep(1) # Loading bar simulation time.sleep(1) loading_steps = [ " ⣠⣤⣶⣶⣦⣄⣀", "⠀ ⢰⣿⣿⣿⣿⣿⣿⣿⣷⣦⡀", "⠀ ⠀ ⢠⣷⣤⠀⠈⠙⢿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀", " ⠀ ⠀⠀⣠⣿⣿⣿⠆⠰⠶⠀⠘⢿⣿⣿⣿⣿⣿⣆⠀⠀⠀", "⠀ ⠀ ⢀⣼⣿⣿⣿⠏⠀⢀⣠⣤⣤⣀⠙⣿⣿⣿⣿⣿⣷⡀⠀", " ⠀ ⠀⡴⢡⣾⣿⣿⣷⠋⠁⣿⣿⣿⣿⣿⣿⣿⠃⠀⡻⣿⣿⣿⣿⡇", "⠀⠀ ⢀⠜⠁⠸⣿⣿⣿⠟⠀⠀⠘⠿⣿⣿⣿⡿⠋⠰⠖⠱⣽⠟⠋⠉⡇", "⠀⠀ ⡰⠉⠖⣀⠀⠀⢁⣀⠀⣴⣶⣦⠀⢴⡆⠀⠀⢀⣀⣀⣉⡽⠷⠶⠋⠀", "⠀ ⠀⡰⢡⣾⣿⣿⣿⡄⠛⠋⠘⣿⣿⡿⠀⠀⣐⣲⣤⣯⠞⠉⠁⠀⠀⠀⠀⠀", " ⢀⠔⠁⣿⣿⣿⣿⣿⡟⠀⠀⠀⢀⣄⣀⡞⠉⠉⠉⠉⠁⠀⠀⠀⠀⠀", " ⠀⡜⠀⠀⠻⣿⣿⠿⣻⣥⣀⡀⢠⡟⠉⠉⠀⠀⠀⠀⠀", " ⢰⠁⠀⡤⠖⠺⢶⡾⠃⠀⠈⠙⠋⠀⠀⠀⠀⠀", " ⠈⠓⠾⠇⠀⠀⠀⠀" ] for step in loading_steps: print(step) time.sleep(1) print("Your order has been confirmed! Please allow 10-25 minutes for your pizzas to be ready! 🍕🎈") print("Thank you for visiting Whanau Pizzeria! Have a great day!")