Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Importing different systems, as they are needed later in the program
- import sys
- import string
- #Subsitute variable for the cancel() function
- var1 = "Nothing"
- #Used in 'tolong()' function for maximum of characters for input
- maxchar = 100
- #The total cost the user has to pay
- total_cost = 0
- #The Regular and Gourmet Pizza Lists
- pizza_r = ["Chicken Vege", "Vegetarian", "Meat Lovers", "Super Vege", "Beef Surpreme", "Chicken Supreme", "Super Supreme"]
- pizza_g = ["Italiano", "Mexician", "BBQ Chicken & Bacon", "BBQ Beef & Bacon", "Lemon Pepper Chicken"]
- #All the pizzas the user has ordered
- order_all = []
- #Pizza price for pizzas, after user has ordered them
- pizza_cost = []
- #If it gets deliveried it will add the extra cost the final order
- shipping = 0
- #For any 'Are you sure' potiental functions
- sure = 0
- #Customer's Name
- cus = "empty"
- #Customer's Address
- address = "empty"
- #Customer's Phone Number
- phone_num = "0"
- #If a input that shouldn't be in there comes up
- def error():
- print("This shouldn't be a possible input, system shutting down!")
- sys.exit()
- #Prints a new line for a new section, so the whole thing doesn't have to be typed everytime
- def line():
- print("_______________________________________________________________,")
- print("")
- #Returns a line for .format(), so the whole line doesn't have to be typed everytime
- def line1():
- return("______________________________________________________________,")
- #Prints a breaker line, to break up each part of a section
- def linea():
- print("---------------------------------------------------------------'")
- #Returns a breaker line for .format()
- def linea1():
- return("--------------------------------------------------------------'")
- #Big line so the user knows well and clear its a new section
- def bigline():
- line()
- print("""
- """)
- line()
- #Prints a statement for invalid input
- def checker():
- global sure
- if sure == 0:
- bigline()
- print("That is not an option, Please try something else.")
- else:
- sure = 0
- #Prints a statement for inputs to long
- def tolong(maxchar):
- bigline()
- print("Your exceeded the maximum amount of characters, Please retry with less than {} characters.".format(maxchar))
- #Cancelling Text for strings
- def can_txt():
- return ("0: If you would like to cancel your order, press '0'")
- #Cancelling Function to put in after Cancelling Text
- def cancel(var1):
- while True:
- if var1 in (0, "0"):
- line()
- confirm_a = input("""Are you sure you want to cancel your order?
- {}
- 1: Yes
- 2: No
- {}
- Input: """.format(linea1(), linea1()))
- #Checks for valid input
- if confirm_a in "1":
- line()
- print("Your order was cancelled, have a nice day!")
- sys.exit()
- elif confirm_a in "2":
- global sure
- sure = 1
- break
- else:
- checker()
- else:
- break
- #Asks Users for either Delivery or Pick Up
- def delivery():
- global total_cost
- total_cost = 0
- while True:
- line()
- global del_or_pick
- del_or_pick = input("""Hello, How would you like to recieve your pizza?
- {}
- 1: Delivered to your house ($3 Delivery Fees)
- 2: You pick up
- {}
- {}
- Input: """.format(linea1(), can_txt(), linea1()))
- cancel(del_or_pick)
- #Checks for valid input
- if del_or_pick in ("1", "2"):
- break
- else:
- checker()
- #Asks user for Name
- def name():
- while True:
- line()
- global cus
- if cus in "empty":
- cus = input("""What is your name?
- {}
- {}
- {}
- Input: """.format(linea1(), can_txt(), linea1()))
- cancel(cus)
- cus.lower().capitalize()
- #Checks for valid input
- if cus.isalpha() == False:
- cus = "empty"
- checker()
- else:
- maxchar = 25
- if len(cus) >= 25:
- cus = "empty"
- tolong(maxchar)
- else:
- break
- elif cus != "empty":
- break
- else:
- error()
- #Asks Users for personal info if delivery
- def delivery_d():
- global total_cost
- total_cost += 3
- global shipping
- shipping == 1
- line()
- print("We will need your name, address and phone number.")
- #Asks user for Name
- name()
- #Asks user for Address
- while True:
- global address
- if address in "empty":
- line()
- address = input("""What is your Address?
- {}
- Please format it like this.
- {}
- [Street], [Suburb], [City], [State], [Postcode]
- {}
- {}
- {}
- Input: """.format(linea1(), linea1(), linea1(), can_txt(), linea1()))
- cancel(address)
- address.lower().capitalize()
- maxchar = 100
- #Checks for valid input
- if len(address) >= 100:
- address = "empty"
- tolong(maxchar)
- else:
- break
- elif address != "empty":
- break
- else:
- error()
- #Asks user for Phone Number
- while True:
- global phone_num
- if phone_num in "0":
- line()
- phone_num = input("""What is your Phone Number?
- {}
- {}
- {}
- Input: """.format(linea1(), can_txt(), linea1()))
- cancel(phone_num)
- #Checks for valid input
- if phone_num.isdigit() == True:
- maxchar = 20
- if len(phone_num) <= 25:
- break
- else:
- tolong(maxchar)
- else:
- checker()
- elif phone_num != "0":
- break
- else:
- error()
- def delivery_p():
- line()
- print("You have decided to pick up, could we please have your name?")
- #Asks user for there name
- name()
- #Function for current pizza order
- def pizza_current():
- line()
- print("Your current order of pizzas is:")
- linea()
- cost_list = 0
- for orde in order_all:
- print("{} Pizza | {}".format(orde, pizza_cost[cost_list]))
- cost_list += 1
- linea()
- print("Your current total cost is: ${}0".format(total_cost))
- def pizza():
- while True:
- #Prints all the pizzas the user can order
- line()
- print("""Hello {}, what pizza would you like to order, here is our list
- {}
- Regular Pizzas | $8.50 each
- {}""".format(cus, linea1(), linea1()))
- numbera = 1
- for pizza in pizza_r:
- print("{}: {}".format(numbera, pizza))
- numbera += 1
- print("""{}
- Gourmet Pizzas | $12.50 each
- {}""".format(linea1(), linea1()))
- for pizza in pizza_g:
- print("{}: {}".format(numbera, pizza))
- numbera += 1
- linea()
- #Asks the user which pizza they would like to order
- print("#: If you don't want to order another pizza, press '#'")
- order = input("""{}
- {}
- Input: """.format(can_txt(), linea1()))
- cancel(order)
- #Checks if user doesn't want to order another pizza
- if order in ("#"):
- #Checks to see if the user has ordered anything
- if len(order_all) == 0:
- bigline()
- print("You have not ordered a pizza, please order a pizza or cancel your order!")
- else:
- break
- #Checks for valid input
- if order.isdigit() == True:
- order = int(order)
- if order in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12):
- global total_cost
- global pizza_cost
- if len(order_all) <= 4:
- #Checks if the selected pizza is a regular pizza and adds it to the list, as well as adding $8.50 to the total cost
- if order in (1, 2, 3, 4, 5, 6, 7):
- total_cost += 8.5
- order -= 1
- order_all.append(pizza_r[int("{}".format(order))])
- pizza_cost.append("$8.50")
- #Checks if the selected pizza is a gourmet pizza and adds it to the list, as well as adding $12.50 to the total cost
- elif order in (8, 9, 10, 11, 12):
- total_cost += 12.5
- order -= 8
- order_all.append(pizza_g[int("{}".format(order))])
- pizza_cost.append("$12.50")
- else:
- error()
- line()
- #Asks user if they want to add another pizza to there order
- confirm = input("""Would you like to add another pizza to your order?
- {}
- 1: Yes
- 2: No
- {}
- {}
- Input: """.format(linea1(), can_txt(), linea1()))
- cancel(confirm)
- #Checks for valid input
- if confirm == "1":
- pizza_current()
- elif confirm == "2":
- break
- else:
- checker()
- #Checks to see if the user has exceed the maximum amount of pizzas per order, which is currently 5
- elif len(order_all) == 5:
- bigline()
- print("You have a maximum of 5 pizzas per order. You have exceed the maximum amount of 5 pizzas in your order, after you have finished this order, please start another order to get more pizzas.")
- break
- elif len(order_all) >= 6:
- error()
- else:
- checker()
- if len(order_all) >= 1:
- pizza_current()
- def order_finished():
- while True:
- #Tells the user the there order is finished. Its shows them there ordered pizzas and any extra charges, such as home delivery costs
- line()
- print("Hello again {}, Your order is now finished, here is what you ordered".format(cus))
- linea()
- print("Your Pizzas:")
- linea()
- cost_list = 0
- for orde in order_all:
- print("{} Pizza | {}".format(orde, pizza_cost[cost_list]))
- cost_list += 1
- linea()
- print("Your total cost is: ${}0".format(total_cost))
- linea()
- #Checks if the user wanted home delivery for there pizzas
- if shipping == 1:
- print("Extra Costs:")
- linea()
- print("Home Delivery Costs: $3.50")
- linea()
- print("Address Information:")
- linea()
- print("Your Address: {}".format(address))
- print("Your Phone Number: {}".format(phone_num))
- linea()
- elif shipping == 0:
- pass
- else:
- error()
- #Asks the user if they want to confirm there order
- order_confirm = input("""Would you like to confirm your order?
- {}
- 1: Yes
- {}
- {}
- Input: """.format(linea1(), can_txt(), linea1()))
- cancel(order_confirm)
- line()
- #Checks for valid input
- if order_confirm in "1":
- #Tells the user there order is confirmed and is getting delivered, if they choose delivery
- if del_or_pick in "1":
- print("Your order is confirmed and is being delivered to you now. Have a nice day.")
- linea()
- break
- #Tells the user there order is confirmed and there order is ready to pick, if they choose pick up
- elif del_or_pick in "2":
- print("Your order is confirmed and ready for you to pick it up. Have a nice day.")
- line1()
- break
- else:
- error()
- else:
- checker()
- while True:
- #Asks user if they want to start another order
- print("Would you like to start another order?")
- linea()
- confirm_a = input("""1: Yes
- 2: No
- {}
- Input: """.format(linea1()))
- #Checks for valid input
- if confirm_a == "1":
- line()
- print("New order starting. Thanks for the ordering here.")
- break
- elif confirm_a == "2":
- line()
- print("Thanks for ordering here. Hope to see you again soon.")
- sys.exit()
- else:
- line()
- checker()
- #Main line of code
- while True:
- delivery()
- if del_or_pick in "1":
- delivery_d()
- elif del_or_pick in "2":
- delivery_p()
- else:
- error()
- pizza()
- order_finished()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement