-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathITERATION 1
267 lines (202 loc) · 7.4 KB
/
ITERATION 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#ITERATION 1: CAFE MENU
# SPECIFICATIONS: ||| 1. Login and Sign Up ||| 2. Menu ||| 3. Billing |||
#Introduction to program
#Offers choice to log in or create account.
#Checks for correct Student ID and password in index data (list)
#Checks for age for new users and saves Student ID and password in a list.
#Displays Café menu and asks for orders – items, quantity.
#Displays invoice with details of items, quantity, price and total.
#VARIABLES
#Login/Signup Variables
student_id = []
password = []
user = []
age = []
users = []
current_user = []
#Menu Variables
hot_drinks = {"Hot chocolate": 4, "Latte": 4, "Mochaccino": 4, "Cuppaccino": 4, "Long black": 4, "Flat white": 4, "- GST per items above":"0.6\n\n"}
cold_drinks ={"Milkshake": 5, "Thickshake": 5, "Icedcoffee": 5, "Icedtea": 5, "Icedchocolate": 5, "Softdrinks": 5,"- GST per item above": "0.75\n\n"}
snacks ={"Donut": 3.5, "Hashbrown": 3.5,"Sandwiches":3.5,"Chips":3.5,"Salad":3.5,"- GST per item above": "0.53\n\n"}
lunch = {"Hot dog": 7.5, "Burgers":7.5,"Wraps":5,"Steam buns":6,"Sushi":7,"Noodles":5,"Pies":4}
menu = {}
menu.update(hot_drinks)
menu.update(cold_drinks)
menu.update(snacks)
menu.update(lunch)
#Billing and Ordering Variables
order = {}
orders = []
user_orders = []
item = []
price = []
total = []
quantity=[]
#FUNCTIONS
#---Adding Orders--#
def add_order(user, order, orders):
orders.append((user, order))
#Adds the student ID password and age of user and adds the item they chose
#Orders is added the the variable orders
#---Login in--#
def login(users):
#Asks user for Student ID and password
student_id = input("Enter Student ID: ")
password = input("Enter password: ")
#if a user is already a member
for user in users:
#If student ID and password is correct for the user
if user[0] == student_id and user[1] == password:
print(f"Welcome back, {student_id}!")
return user
#If user is not a member
print("Invalid Student ID or password.")
return None
#---Sign Up--#
def signup(users):
try:
#Asks user to enter a Student ID, Password and Age
student_id = input("Enter Student ID: ")
password = input("Enter password: ")
age = int(input("Enter your age: "))
#If they are not an eligible
if age < 13:
print("Sorry, you must be 13 or older to create an account.")
return None
#The user cannot be over 20 years old as they must be a school student for BDSC (yr 9 - yr13)
elif age > 18:
print("Sorry you must be a BDSC Student therefore you cannot be 20 years or older")
return None
#if they are over 13 and under 21
#Adds the Student ID, password and age to the variable users.
user = (student_id, password, age)
users.append(user)
print(f"Account created for {student_id}!")
return user
#If There is ValueError Present Within The signup function
except ValueError:
print("Please enter an appropriate answer for an age \n\n")
signup(users)
#--Display Menu--#
def display_menu(menu):
#Prints out the Menu, the items and the price next to it
print("""
MENU:
Hot Drinks $4:
- Hot Chocolate
- Latte
- Mochaccino
- Cuppaccino
- Long black
- Flat White
Cold Drinks $5:
- Milkshake
- Thickshake
- Iced Coffee
- Iced Tea
- Iced Chocolate
- Soft Drinks
Snacks $3.50:
- Donut
- Hashbrown
- Sandwiches (gourmet)
- Salad
- Chips
Lunch:
- HotDog $7.50
- Burger $7.50
- Wraps $5
- Steam Buns $6
- Sushi $7
- Noodles $5
- Pies $4
""")
#--Order Food--#
def order_food(current_user, menu, orders):
try:
global order
while True:
# Asks user for item they would like to purchase
item = input("Enter item name (or 'done' to finish): ").capitalize()
#If the user inputs done, then it closes this and returns them to the run function
if item == "Done":
break
#If user inputs an item that is not in the list, then it returns them to order food function
if item not in menu:
print("Sorry, we don't have that item.")
continue
# Asks user for quantity of item they would like to purchase, and then adds the item to the order variable
quantity = int(input("Enter quantity: "))
order[item] = order.get(item, 0) + quantity
#Goes to the add order function
add_order(current_user, order, orders)
print("Order placed successfully!")
#If ValueError is found within order_food function
except ValueError:
print("Please enter an appropriate answer for an quantity \n\n")
order_food(current_user, menu, orders)
#--View Order--#
def view_orders(current_user, menu, orders):
# User order is item and quantity for the current user.
user_orders = [order for user, order in orders if user == current_user]
#if not in user order, then it returns to run function
if not user_orders:
print("No orders found for this user.")
return
print("\nYour Orders:")
#prints out the number of order
for i, order in enumerate(user_orders, 1):
print(f"\nOrder {i}:")
#For number or items and quantities within the variable order, it then calculates the total price
for item, quantity in order.items():
price = menu[item]
total = price * quantity
print(f"{item} ${price} x {quantity} = ${total}")
#Prints the total sum of all orders
print(f"Total: ${sum(menu[item]*quantity for item, quantity in order.items())}")
#--Main Program--#
def run():
#Start of program
global menu
users = []
current_user = None
orders = []
print("Welcome to our Cafe!")
#Presents the user with the choices
while True:
print("\n1. Login\n2. Signup\n3. Display Menu\n4. Order Food\n5. View Orders\n6. Exit")
choice = input("Enter choice: ")
#Login option
if choice == "1":
current_user = login(users)
#Sign Up option
elif choice == "2":
current_user = signup(users)
#Display Menu option
elif choice == "3":
display_menu(menu)
#Ordering food option
elif choice == "4":
#If their is no current user, then it will say please login/signup
if not current_user:
print("Please login/signup first.")
#Else it will go to the order menu function
else:
order_food(current_user, menu, orders)
#Viewing order option
elif choice == "5":
#If current user is none, then it will say please login/signup
if not current_user:
print("Please login/signup first.")
#Else it will do the view order function
else:
view_orders(current_user, menu, orders)
#Ends the Program
elif choice == "6":
print("Thank you for visiting us!")
break
#If anything else is pressed but option presented the it will say invalid choice, then do the run function
else:
print("Invalid choice, please try again.")
#Runs the program
run()