SHARE
TWEET

Untitled

a guest Sep 19th, 2016 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Importing different systems, as they are needed later in the program
  2. import sys
  3. import string
  4. #Subsitute variable for the cancel() function
  5. var1 = "Nothing"
  6. #Used in 'tolong()' function for maximum of characters for input
  7. maxchar = 100
  8. #The total cost the user has to pay
  9. total_cost = 0
  10. #The Regular and Gourmet Pizza Lists
  11. pizza_r = ["Chicken Vege", "Vegetarian", "Meat Lovers", "Super Vege", "Beef Surpreme", "Chicken Supreme", "Super Supreme"]
  12. pizza_g = ["Italiano", "Mexician", "BBQ Chicken & Bacon", "BBQ Beef & Bacon", "Lemon Pepper Chicken"]
  13. #All the pizzas the user has ordered
  14. order_all = []
  15. #Pizza price for pizzas, after user has ordered them
  16. pizza_cost = []
  17. #If it gets deliveried it will add the extra cost the final order
  18. shipping = 0
  19. #For any 'Are you sure' potiental functions
  20. sure = 0
  21. #Customer's Name
  22. cus = "empty"
  23. #Customer's Address
  24. address = "empty"
  25. #Customer's Phone Number
  26. phone_num = "0"
  27.  
  28. #If a input that shouldn't be in there comes up
  29. def error():
  30.     print("This shouldn't be a possible input, system shutting down!")
  31.     sys.exit()
  32.  
  33. #Prints a new line for a new section, so the whole thing doesn't have to be typed everytime
  34. def line():
  35.     print("_______________________________________________________________,")
  36.     print("")
  37.  
  38. #Returns a line for .format(), so the whole line doesn't have to be typed everytime
  39. def line1():
  40.     return("______________________________________________________________,")
  41.  
  42. #Prints a breaker line, to break up each part of a section
  43. def linea():
  44.     print("---------------------------------------------------------------'")
  45.  
  46. #Returns a breaker line for .format()
  47. def linea1():
  48.     return("--------------------------------------------------------------'")
  49.  
  50. #Big line so the user knows well and clear its a new section
  51. def bigline():
  52.     line()
  53.     print("""
  54.  
  55.  
  56.  
  57. """)
  58.     line()
  59.  
  60. #Prints a statement for invalid input
  61. def checker():
  62.     global sure
  63.     if sure == 0:
  64.         bigline()
  65.         print("That is not an option, Please try something else.")
  66.     else:
  67.         sure = 0
  68.  
  69. #Prints a statement for inputs to long
  70. def tolong(maxchar):
  71.     bigline()
  72.     print("Your exceeded the maximum amount of characters, Please retry with less than {} characters.".format(maxchar))
  73.  
  74. #Cancelling Text for strings
  75. def can_txt():
  76.     return ("0: If you would like to cancel your order, press '0'")
  77.  
  78. #Cancelling Function to put in after Cancelling Text
  79. def cancel(var1):
  80.     while True:
  81.         if var1 in (0, "0"):
  82.             line()
  83.             confirm_a = input("""Are you sure you want to cancel your order?
  84. {}
  85. 1: Yes
  86. 2: No
  87. {}
  88. Input: """.format(linea1(), linea1()))
  89.             #Checks for valid input
  90.             if confirm_a in "1":
  91.                 line()
  92.                 print("Your order was cancelled, have a nice day!")
  93.                 sys.exit()
  94.             elif confirm_a in "2":
  95.                 global sure
  96.                 sure = 1
  97.                 break
  98.             else:
  99.                 checker()
  100.         else:
  101.             break
  102.        
  103.  
  104. #Asks Users for either Delivery or Pick Up
  105. def delivery():
  106.     global total_cost
  107.     total_cost = 0
  108.     while True:
  109.         line()
  110.         global del_or_pick
  111.         del_or_pick = input("""Hello, How would you like to recieve your pizza?
  112. {}
  113. 1: Delivered to your house ($3 Delivery Fees)
  114. 2: You pick up
  115. {}
  116. {}
  117. Input: """.format(linea1(), can_txt(), linea1()))
  118.         cancel(del_or_pick)
  119.         #Checks for valid input
  120.         if del_or_pick in ("1", "2"):
  121.             break
  122.         else:
  123.             checker()
  124.  
  125. #Asks user for Name
  126. def name():
  127.     while True:
  128.         line()
  129.         global cus
  130.         if cus in "empty":
  131.             cus = input("""What is your name?
  132. {}
  133. {}
  134. {}
  135. Input: """.format(linea1(), can_txt(), linea1()))
  136.             cancel(cus)
  137.             cus.lower().capitalize()
  138.             #Checks for valid input
  139.             if cus.isalpha() == False:
  140.                 cus = "empty"
  141.                 checker()
  142.             else:
  143.                 maxchar = 25
  144.                 if len(cus) >= 25:
  145.                     cus = "empty"
  146.                     tolong(maxchar)
  147.                 else:
  148.                     break
  149.         elif cus != "empty":
  150.             break
  151.         else:
  152.             error()
  153.    
  154.  
  155. #Asks Users for personal info if delivery
  156. def delivery_d():
  157.     global total_cost
  158.     total_cost += 3
  159.     global shipping
  160.     shipping == 1
  161.     line()
  162.     print("We will need your name, address and phone number.")
  163.     #Asks user for Name
  164.     name()
  165.            
  166.     #Asks user for Address    
  167.     while True:
  168.         global address
  169.         if address in "empty":
  170.             line()
  171.             address = input("""What is your Address?
  172. {}
  173. Please format it like this.
  174. {}
  175. [Street], [Suburb], [City], [State], [Postcode]
  176. {}
  177. {}
  178. {}
  179. Input: """.format(linea1(), linea1(), linea1(), can_txt(), linea1()))
  180.             cancel(address)
  181.             address.lower().capitalize()
  182.             maxchar = 100
  183.             #Checks for valid input
  184.             if len(address) >= 100:
  185.                 address = "empty"
  186.                 tolong(maxchar)
  187.             else:
  188.                 break
  189.         elif address != "empty":
  190.             break
  191.         else:
  192.             error()
  193.            
  194.  
  195.     #Asks user for Phone Number
  196.     while True:
  197.         global phone_num
  198.         if phone_num in "0":
  199.             line()
  200.             phone_num = input("""What is your Phone Number?
  201. {}
  202. {}
  203. {}
  204. Input: """.format(linea1(), can_txt(), linea1()))
  205.             cancel(phone_num)
  206.             #Checks for valid input
  207.             if phone_num.isdigit() == True:
  208.                 maxchar = 20
  209.                 if len(phone_num) <= 25:
  210.                     break
  211.                 else:
  212.                     tolong(maxchar)
  213.             else:
  214.                 checker()
  215.         elif phone_num != "0":
  216.             break
  217.         else:
  218.             error()
  219.  
  220. def delivery_p():
  221.     line()
  222.     print("You have decided to pick up, could we please have your name?")
  223.     #Asks user for there name
  224.     name()
  225.  
  226. #Function for current pizza order
  227. def pizza_current():
  228.     line()
  229.     print("Your current order of pizzas is:")
  230.     linea()
  231.     cost_list = 0
  232.     for orde in order_all:
  233.         print("{} Pizza | {}".format(orde, pizza_cost[cost_list]))
  234.         cost_list += 1
  235.     linea()
  236.     print("Your current total cost is: ${}0".format(total_cost))
  237.  
  238. def pizza():
  239.     while True:
  240.         #Prints all the pizzas the user can order
  241.         line()
  242.         print("""Hello {}, what pizza would you like to order, here is our list
  243. {}
  244. Regular Pizzas | $8.50 each
  245. {}""".format(cus, linea1(), linea1()))
  246.         numbera = 1
  247.         for pizza in pizza_r:
  248.             print("{}: {}".format(numbera, pizza))
  249.             numbera += 1
  250.         print("""{}
  251. Gourmet Pizzas | $12.50 each
  252. {}""".format(linea1(), linea1()))
  253.         for pizza in pizza_g:
  254.             print("{}: {}".format(numbera, pizza))
  255.             numbera += 1
  256.         linea()
  257.         #Asks the user which pizza they would like to order
  258.         print("#: If you don't want to order another pizza, press '#'")
  259.         order = input("""{}
  260. {}
  261. Input: """.format(can_txt(), linea1()))
  262.         cancel(order)
  263.         #Checks if user doesn't want to order another pizza
  264.         if order in ("#"):
  265.             #Checks to see if the user has ordered anything
  266.             if len(order_all) == 0:
  267.                 bigline()
  268.                 print("You have not ordered a pizza, please order a pizza or cancel your order!")
  269.             else:
  270.                 break
  271.         #Checks for valid input
  272.         if order.isdigit() == True:
  273.             order = int(order)
  274.         if order in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12):
  275.             global total_cost
  276.             global pizza_cost
  277.             if len(order_all) <= 4:
  278.                 #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
  279.                 if order in (1, 2, 3, 4, 5, 6, 7):
  280.                     total_cost += 8.5
  281.                     order -= 1
  282.                     order_all.append(pizza_r[int("{}".format(order))])
  283.                     pizza_cost.append("$8.50")
  284.                 #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
  285.                 elif order in (8, 9, 10, 11, 12):
  286.                     total_cost += 12.5
  287.                     order -= 8
  288.                     order_all.append(pizza_g[int("{}".format(order))])
  289.                     pizza_cost.append("$12.50")
  290.                 else:
  291.                     error()
  292.                 line()
  293.                 #Asks user if they want to add another pizza to there order
  294.                 confirm = input("""Would you like to add another pizza to your order?
  295. {}
  296. 1: Yes
  297. 2: No
  298. {}
  299. {}
  300. Input: """.format(linea1(), can_txt(), linea1()))
  301.                 cancel(confirm)
  302.                 #Checks for valid input
  303.                 if confirm == "1":
  304.                     pizza_current()
  305.                 elif confirm == "2":
  306.                     break
  307.                 else:
  308.                      checker()
  309.             #Checks to see if the user has exceed the maximum amount of pizzas per order, which is currently 5
  310.             elif len(order_all) == 5:
  311.                 bigline()
  312.                 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.")
  313.                 break
  314.             elif len(order_all) >= 6:
  315.                 error()
  316.         else:
  317.             checker()
  318.             if len(order_all) >= 1:
  319.                 pizza_current()
  320.  
  321. def order_finished():
  322.     while True:
  323.         #Tells the user the there order is finished. Its shows them there ordered pizzas and any extra charges, such as home delivery costs
  324.         line()
  325.         print("Hello again {}, Your order is now finished, here is what you ordered".format(cus))
  326.         linea()
  327.         print("Your Pizzas:")
  328.         linea()
  329.         cost_list = 0
  330.         for orde in order_all:
  331.             print("{} Pizza | {}".format(orde, pizza_cost[cost_list]))
  332.             cost_list += 1
  333.         linea()
  334.         print("Your total cost is: ${}0".format(total_cost))
  335.         linea()
  336.         #Checks if the user wanted home delivery for there pizzas
  337.         if shipping == 1:
  338.             print("Extra Costs:")
  339.             linea()
  340.             print("Home Delivery Costs: $3.50")
  341.             linea()
  342.             print("Address Information:")
  343.             linea()
  344.             print("Your Address: {}".format(address))
  345.             print("Your Phone Number: {}".format(phone_num))
  346.             linea()
  347.         elif shipping == 0:
  348.             pass
  349.         else:
  350.             error()
  351.         #Asks the user if they want to confirm there order
  352.         order_confirm = input("""Would you like to confirm your order?
  353. {}
  354. 1: Yes
  355. {}
  356. {}
  357. Input: """.format(linea1(), can_txt(), linea1()))
  358.         cancel(order_confirm)
  359.         line()
  360.         #Checks for valid input
  361.         if order_confirm in "1":
  362.             #Tells the user there order is confirmed and is getting delivered, if they choose delivery
  363.             if del_or_pick in "1":
  364.                 print("Your order is confirmed and is being delivered to you now. Have a nice day.")
  365.                 linea()
  366.                 break
  367.             #Tells the user there order is confirmed and there order is ready to pick, if they choose pick up
  368.             elif del_or_pick in "2":
  369.                 print("Your order is confirmed and ready for you to pick it up. Have a nice day.")
  370.                 line1()
  371.                 break
  372.             else:
  373.                 error()
  374.         else:
  375.             checker()
  376.     while True:
  377.         #Asks user if they want to start another order
  378.         print("Would you like to start another order?")
  379.         linea()
  380.         confirm_a = input("""1: Yes
  381. 2: No
  382. {}
  383. Input: """.format(linea1()))
  384.         #Checks for valid input
  385.         if confirm_a == "1":
  386.             line()
  387.             print("New order starting. Thanks for the ordering here.")
  388.             break
  389.         elif confirm_a == "2":
  390.             line()
  391.             print("Thanks for ordering here. Hope to see you again soon.")
  392.             sys.exit()
  393.         else:
  394.             line()
  395.             checker()
  396.  
  397. #Main line of code
  398. while True:
  399.     delivery()
  400.     if del_or_pick in "1":
  401.         delivery_d()
  402.     elif del_or_pick in "2":
  403.         delivery_p()
  404.     else:
  405.         error()
  406.     pizza()
  407.     order_finished()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top