import re
running = True
global menu
global prices
deliveryCost = 2
menu = ["Egg McMuffin", "Sausage McGriddle", "Hash Browns", "Big Mac", "McDouble", "Cheeseburger", "McChicken", "Filet-O-Fish", "Chicken McNuggets", "Iced Coffe", "Soft Drink", "Water", "Happy Meal", "French Fries", "Salad"]
prices = [2.79, 2.79, 1.09, 3.99, 1.39, 1.00, 1.29, 3.79, 4.49, 1.79, 1.29, 1.00, 3.00, 1.79, 4.59]
cost = []
customerOrder = []
def fillInfo():
print("Welcome to the McDonald's Python ordering service!")
print("Please fill out the following information. Press enter after each entry. Also, keep in mind that there is a $2 delivery fee.")
print("")
while running == True:
global customer_name
customer_name = input("Name:")
if not re.match("^[a-zA-Z ]*$", customer_name):
print("Please use letters only")
elif len(customer_name) == 0:
print("Please enter a valid input")
else:
customer_name = customer_name.title()
break
while running == True:
global phone
phone = input("Phone number:")
if not re.match("^[0-9 ]*$", phone):
print("Please use numbers only")
elif len(phone) == 0:
print("Please enter a valid input")
else:
break
while running == True:
global address
address = input("Street address:")
if len(address) == 0:
print("Please enter a valid input")
else:
address = address
break
while running == True:
global city
city = input("City:")
if not re.match("^[a-zA-Z ]*$", city):
print("Please use letters only")
elif len(city) == 0:
print("Please enter a valid input")
else:
city = city.title()
break
while running == True:
global zipcode
zipcode = input("Zipcode:")
if not re.match("^[0-9 /]*$", zipcode):
print("Please use numbers only")
elif len(zipcode) == 0 or len(zipcode) > 5:
print("Please enter a valid zipcode (no more than 5 digits)")
else:
break
fillInfo()
def print_menu():
print ("""
-----------------------------------------------
| MCDONALD'S MENU |
| |
| Breakfast |
| ----------------------------- |
| 1. Egg McMuffin $2.79 |
| 2. Sausage McGriddle $2.79 |
| 3. Hash Browns $1.09 |
| |
| Burgers |
| ----------------------------- |
| 4. Big Mac $3.99 |
| 5. McDouble $1.39 |
| 6. Cheeseburger $1.00 |
| |
| Chicken & Sandwiches |
| ----------------------------- |
| 7. McChicken $1.29 |
| 8. Filet-O-Fish $3.79 |
| 9. Chicken McNuggets $4.49 |
| |
| Drinks |
| ----------------------------- |
| 10. Iced Coffee $1.79 |
| 11. Soft Drink $1.29 |
| 12. Water $1.00 |
| |
| Other |
| ----------------------------- |
| 13. Happy Meal $3.00 |
| 14. French Fries $1.79 |
| 15. Salad $4.59 |
| |
-----------------------------------------------
""")
print_menu()
def order():
global item_num
while True:
try:
item_num = int(input("How many items would you like to order? The minimum is 1 and the max is 5:"))
if item_num < 1:
print("Please order between 1 and 5 items")
continue
if item_num > 5:
print("Please order between 1 and 5 items")
continue
else:
break
except ValueError:
print("Please use numbers only")
continue
order()
def itemChoice():
for i in range(1,item_num+1):
while True:
try:
which_item = int(input("Enter the number of the item you would like to add to your order:"))
if which_item < 1:
print("Refer to menu for the item number")
continue
if which_item > 15:
print("Refer to menu for the item number")
continue
else:
item = which_item - 1
cost.append(prices[item])
customerOrder.append(menu[item])
global total_cost
total_cost = round(sum(cost),2)
global grandTotal
grandTotal = round(total_cost + deliveryCost, 2)
break
except ValueError:
print("Please use numbers only")
continue
itemChoice()
def customerDetails():
print ("")
print ("CUSTOMER and ORDER DETAILS")
print ("")
print ("Name:", customer_name)
print ("Phone number:", phone)
print ("Address:", address)
print (" ", city)
print (" ", zipcode)
print ("ORDER:", customerOrder)
print ("Total: $", total_cost)
print ("Total + Delivery: $", grandTotal)
customerDetails()
print ("")
def confirm():
confirmation = input("Enter Y to confirm your order, or enter N to reset the order:")
confirmation = confirmation.upper()
if confirmation == "Y":
print("ORDER CONFIRMED")
elif confirmation == "N":
print("ORDER CANCELLED - information has been reset")
customerOrder[:] = []
cost[:] = []
print_menu()
order()
itemChoice()
customerDetails()
confirm()
else:
print("Please enter Y or N")
confirm()
confirm()
def goodbye():
print ("")
print ("THANK YOU FOR YOUR ORDER")
print ("Your order will be delivered in 15 minutes")
bye = input("Type 'exit' to end the McDonald's Python ordering service:")
print ("")
def orderAgain():
order_more = input("Enter Z to order more, or enter X to exit the program:")
order_more = order_more.upper()
if order_more == "Z":
print_menu()
order()
itemChoice()
customerDetails()
confirm()
goodbye()
elif order_more == "X":
goodbye()
else:
print ("Please enter X or Z")
orderAgain()
orderAgain()
Very cool program! Simple and easy to understand.
ReplyDelete