-
Notifications
You must be signed in to change notification settings - Fork 0
/
order_function.py
75 lines (65 loc) · 2 KB
/
order_function.py
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
#### Restaurent Order System using Function
# check input numeric validation
def numeric_validation(value):
""""
This function take an input as interger
and validate that it takes onlu numeric data.
"""
while True:
try:
val = int(input(value))
except:
print('Please use numeric digits.')
continue
if val < 0:
print('Please enter a positive number.')
continue
else:
break
return val
# Add Order items
def order_items(orders):
order_items.total_price = 0
run = True
while run:
orderList = orders
items = numeric_validation("Enter Item No:")
if (items in orderList):
print("Already ordered!!! Try Somthing New")
continue
else:
items_no = int(items)
qty = numeric_validation("Quantity:")
order_items.total_price += (menue[items_no]['price'] * qty)
orderList.append(menue[items_no]['item'])
order = input("Do you want to order more? y/n:")
if order == 'y':
continue
else:
run = False
return order_items
## Start main function
print("#"*30+"\n Welcome To Hacker Caffe\n"+"#"*30+ \
"\nPlease Chose your Order Number:")
# Declare Variables
menue = { 1:{"item":"coffe","price":350},
2:{"item":"burgers","price":250},
3:{"item":"meatloaf","price":220},
4:{"item":"lasagna","price":220}
}
orders = [] # issue it has to be a dictionary not a list
qty= 1
# Show menue
for item,value in menue.items():
print("No#",item,": Item: ",value["item"].title(),"- Price:"+str(value["price"])+"Tk")
print('#'*30)
# Add item
order_items(orders)
print('#'*30)
# Show card list
print("You order the follwing Items: ")
for i in range(len(orders)):
print(str(i+1)+"- "+orders[i].title())
print("-"*30+"\nYour Total Price: "+str(order_items.total_price)+"Tk")
#End
print('#'*30+"\nThanks! Order Again.\n")