Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.15 KB | None | 0 0
  1. # Pizza Perfection
  2. import random # Imports the Random Module
  3. import time
  4. from Menu import *
  5. checkout = 0
  6. checkout_words = None
  7. #-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
  8. def Register_Username():
  9. global username
  10. username = input("Before you start, you must register. Please enter a suitable username: ")
  11. print("Thank you.\n")
  12. Register_Password()
  13. #-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
  14. def Register_Password():
  15. global password
  16. password = input("Please enter a password. It must be at least 8 characters long: ")
  17. while len(password) < 8:
  18. print("This password is too short.")
  19. Register_Password()
  20. print("Thank you. You have successfully registered and may now access the system.")
  21. Menu()
  22. #-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
  23. def Login_Username():
  24. while True:
  25. try:
  26. if username == username:
  27. break
  28. except NameError:
  29. print("You have not successfully registered, please register before accessing the system.")
  30. Menu()
  31. attempted_username = input("\n\n\nPlease login by firstly entering your username: ")
  32. if attempted_username != username:
  33. print("The username entered does not match an account already registered, please try again.")
  34. Login_Username()
  35. else:
  36. Login_Password()
  37. #-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
  38. def Login_Password():
  39. attempted_password = input("\n\nThis username matches a registered account. Please enter the password associated with this account: ")
  40. if attempted_password != password:
  41. print("The password entered does not match with the username entered, please try again.")
  42. Login_Password()
  43. else:
  44. print("You have successfully logged in. You are now being directed to the system.")
  45. PizzaPerfection()
  46. #-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
  47. def PizzaPerfection():
  48. global checkout
  49. print(
  50. """
  51. +-----------|----------------------------------------|-----------+
  52. +-----------| Restaurant Menu: |-----------+
  53. +-----------| 1 - Pizzas |-----------+
  54. +-----------| 2 - Sides |-----------+
  55. +-----------| 3 - Desserts |-----------+
  56. +-----------| 4 - Reset Basket |-----------+
  57. +-----------| 5 - Complete Purchase |-----------+
  58. +-----------|----------------------------------------|-----------+
  59. """
  60. )
  61. print("Current checkout cost: £", checkout,)
  62. print("Current time is:" ,time.ctime())
  63. program = input("Please enter a number from the Menu: ")
  64. if program == "1":
  65. Pizza_Select()
  66. elif program == "2":
  67. Side_Select()
  68. elif program == "3":
  69. Dessert_Select()
  70. elif program == "4":
  71. Reset()
  72. elif program == "5":
  73. Final()
  74. else:
  75. print("That is not a valid option. Try again.")
  76. PizzaPerfection()
  77. #-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
  78. def Pizza_Select():
  79. global checkout
  80. global Pizzas
  81. Pizzas()
  82. pizza_choice = input("We currently offer...\n• (1) Cheese Pizza\n• (2) Pepperoni Pizza\n• (3) Vegetable Pizza\n\nPlease enter the number of the pizza you would like, or type 4 to return: ")
  83. if pizza_choice == "1":
  84. print("1 Cheese Pizza added to your Basket.")
  85. checkout = checkout + cheese_pizza
  86. PizzaPerfection()
  87. elif pizza_choice == "2":
  88. print("1 Pepperoni Pizza added to your Basket.")
  89. checkout = checkout + pepperoni_pizza
  90. PizzaPerfection()
  91. elif pizza_choice == "3":
  92. print("1 Vegetable Pizza added to your Basket.")
  93. checkout = checkout + vegetable_pizza
  94. PizzaPerfection()
  95. elif pizza_choice == "4":
  96. PizzaPerfection()
  97. else:
  98. print("That is not a valid option. Try again.")
  99. Pizza_Select()
  100. #-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
  101. def Side_Select():
  102. global checkout
  103. global Sides
  104. Sides()
  105. chips = 2
  106. onion_rings = 2
  107. side_choice = input("We currently offer...\n• (1) Chips\n• (2) Onion Rings\n\nPlease enter the number of the Side you would like, or type 3 to return: ")
  108. if side_choice == "1":
  109. print("1 Chips added to your Basket.")
  110. checkout = checkout + chips
  111. PizzaPerfection()
  112. elif side_choice == "2":
  113. print("1 Onion Rings added to your Basket.")
  114. checkout = checkout + onion_rings
  115. PizzaPerfection()
  116. elif side_choice == "3":
  117. PizzaPerfection()
  118. else:
  119. print("That is not a valid option. Try again.")
  120. Side_Select()
  121. #-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
  122. def Dessert_Select():
  123. global checkout
  124. global Desserts
  125. dessert_choice = input("We currently offer...\n• (1) Chocolate Cookies\n• (2) Donuts\n• (3) Ice Cream\n\nPlease enter the number of the Dessert you would like, or type 4 to return: ")
  126. if dessert_choice == "1":
  127. print("1 Chocolate Cookies added to your Basket.")
  128. checkout = checkout + chocolate_cookies
  129. PizzaPerfection()
  130. elif dessert_choice == "2":
  131. print("1 Donuts added to your Basket.")
  132. checkout = checkout + donuts
  133. PizzaPerfection()
  134. elif dessert_choice == "3":
  135. print("1 Ice Cream added to your Basket.")
  136. checkout = checkout + ice_cream
  137. PizzaPerfection()
  138. elif dessert_choice == "4":
  139. PizzaPerfection()
  140. else:
  141. print("That is not a valid option. Try again.")
  142. Dessert_Select()
  143. #-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
  144. def Reset():
  145. checkout = 0
  146. print("Basket reset.")
  147. PizzaPerfection()
  148. #-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
  149. def Final():
  150. print("\n\nYour final cost was: £" ,checkout,)
  151. collection_time = time.time() + 1200
  152. print("Your order will be ready for collection at:" ,time.ctime(collection_time))
  153. input("Thanks for your order. Press ENTER to close the system.")
  154. quit()
  155. #-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
  156. def Quit(): # Defining the Function "Quit".
  157. print("You are now quitting the program...") # Alerts the user that the program is now going to quit.
  158. print("Please press the ENTER key.") # Alerts the user on how to close the program completely.
  159. print("If you wish to cancel this, then call the Menu Function using Menu() after pressing 'Cancel' on Quit.") # Lets the user cancel the quit if they would like to.
  160. quit() # This will quit the program.
  161. #-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
  162. def Menu():
  163. print(
  164. """
  165. +-----------|----------------------------------------|-----------+
  166. +-----------| Pizza Perfection: |-----------+
  167. +-----------| 1 - Register |-----------+
  168. +-----------| 2 - Start the system |-----------+
  169. +-----------| 3 - Quit |-----------+
  170. +-----------|----------------------------------------|-----------+
  171. """
  172. )
  173. program = input("Please enter a program number: ")
  174. if program == "1":
  175. Register_Username()
  176. elif program == "2":
  177. Login_Username()
  178. elif program == "3":
  179. Quit()
  180. elif program == "10":
  181. input("This is an administrator only function. Press ENTER to continue.")
  182. username = "admin"
  183. password = "admin"
  184. PizzaPerfection()
  185. else:
  186. print("This is not a valid program number.\nYou are now being returned to the Main Menu.")
  187. Menu()
  188. Menu()
  189. #-=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement