import pandas as pd import time def int_checker(question, low, high): while True: error = f"Enter a number between {low} and {high} or 'd' for done." to_check = input(question).lower() if to_check in ["d", "done"]: return "d" 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 = {k[0]: k for k in valid_ans} 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}") def cash_credit(question): valid_responses = {"c": "cash", "cr": "credit"} while True: response = input(question).lower() if response in valid_responses: return valid_responses[response] elif response in ["cash", "credit"]: return response print("Please choose a valid payment method: 'c' or 'cash' for cash, 'cr' or 'credit' for credit.") 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(): gourmet_toppings_data = { "Item": [ "13: Premium Italian Sausage", "14: Smoked Bacon", "15: Slow Cooked Lamb", "16: Camembert Cheese", "17: Capsicum" ], "Cost": [ "5.50", "3.50", "5.50", "3.50", "4.50" ] } regular_menu_data = { "Item": [ "1: Cheese Sauce", "2: Pesto Sauce", "3: Marinara", "4: Barbeque", "5: Mozzarella Cheese", "6: Ground Beef", "7: Smoked Ham", "8: Pepperoni", "9: Onion", "10: Olives", "11: Spinach", "12: Spring Onion" ], "Cost": [ "1.50", "1.50", "Free", "1.50", "1.50", "3.50", "3.50", "3.50", "2.00", "2.00", "2.00", "1.00" ] } df_gourmet_toppings = pd.DataFrame(gourmet_toppings_data) df_regular_menu = pd.DataFrame(regular_menu_data) print("<--------------- Menu --------------->") print("Gourmet Toppings:") print(df_gourmet_toppings.to_string(index=False, formatters={'Item': '{:<30}'.format, 'Cost': '${:>5}'.format})) print("Pizza Sauces and Toppings:") print(df_regular_menu.to_string(index=False, formatters={'Item': '{:<30}'.format, 'Cost': '${:>5}'.format})) print("\n Small | Medium | Large |") print(" $5 | $7 | $9 |") print(" ------|--------|-------|") 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" "Note: Please only enter one topping at a time\n" ) def get_size_cost(size_option, size_prices): size = string_checker("Choose a size (s/m/l or 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 'd' for done: ", 1, 17) if topping == 'd': 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}...") size, size_cost = get_size_cost(size_option, size_prices) toppings, topping_cost = get_toppings(toppings_menu) 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: size, size_cost, toppings, pizza_total_cost = order_one_pizza(pizza_number, size_option, size_prices, toppings_menu) 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("Order another pizza? (y/n or yes/no): ", ["y", "n", "yes", "no"]) if order_more in ["n", "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.strip() != '': return user_name else: print(error) def order_pizza(): print("<--- Welcome to Whanau Pizzeria --->") print('''⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⢀⣀⣀⣀⣀⡀⠀⠀⠀⢖⠞⠉⠉⠉⠉⠙⢦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠘⠒⢆⢀⣀⣀⣉⡉⠓⢦⢹⠀⠀⡖⠒⣋⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⡄⠀⠀⠀⠀⠀ ⠀⠀⢸⠀⠸⣄⣀⣸⠀⣸⠀⡻⠀⠘⡆⠸⢤⣀⡀⠀⢹⠀⠯⢓⣒⠒⢲⠆⠀⣴⠋⢇⠀⠀⠀⠀⠀ ⠀⣀⠞⠀⣴⠒⠒⠉⠁⠀⣠⠇⠀⠀⣇⠀⠀⠀⡎⡴⠃⠀⠀⡤⠎⢡⠏⠀⠀⢸⢱⣆⢇⠀⠀⠀⠀ ⠘⡆⠀⢠⠇⠀⠀⠀⡏⠁⠀⠀⠀⠀⠀⠉⢦⢠⢷⠁⠀⣴⡋⠀⠀⠮⠤⠤⠤⣧⠈⣯⠈⡆⠀⠀⠀ ⠀⠘⠚⠁⠀⠀⠀⠀⠈⠉⠒⠢⠤⠤⠴⠋⡰⠃⠙⠲⢄⡈⠙⠊⠉⠉⠑⠒⡇⠀⣸⢧⢸⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠓⠒⠒⠢⠤⣌⡇⠀⠀⠀⢠⠃⢀⡇⠘⡜⡄⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⠒⠒⠃⠀⠘⣼ ⠀⠀⠀⠀⠀''') print("In this order system, you will create a custom pizza. Note: All pizza bases are plain. 🍕") want_history = string_checker("\nLearn about the history of Whanau Pizzeria? (y/n or yes/no): ", ["y", "n", "yes", "no"]) if want_history in ["y", "yes"]: history() size_option = ["s", "m", "l", "small", "medium", "large"] size_prices = {"s": 5.00, "m": 7.00, "l": 9.00} toppings_menu = { 1: {'name': "Cheese Sauce", 'cost': 1.50}, 2: {'name': "Pesto Sauce", 'cost': 1.50}, 3: {'name': "Marinara", 'cost': 0.00}, 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} } payment_method = cash_credit("How will you pay? (c for cash, cr for credit): ") if payment_method == "credit": print("Please note a 2% surcharge will apply for credit payments.") 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}") name = not_blank("Enter your name: ") phone_number = int_checker("Enter your phone number: ", 1000000000, 9999999999) address = not_blank("Enter your address: ") print("\nThank you for your order, {name}! We will contact you at {phone_number} to confirm your address: {address}.") time.sleep(2) print("\nYour pizza will be ready soon! 🍕") if __name__ == "__main__": order_pizza()