-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutomatedCoffeeDispenser.py
More file actions
111 lines (99 loc) · 3.19 KB
/
Copy pathAutomatedCoffeeDispenser.py
File metadata and controls
111 lines (99 loc) · 3.19 KB
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
MENU = {
"espresso": {
"ingredients": {
"water": 50,
"coffee": 18,
},
"cost": 1.5,
},
"latte": {
"ingredients": {
"water": 200,
"milk": 150,
"coffee": 24,
},
"cost": 2.5,
},
"cappuccino": {
"ingredients": {
"water": 250,
"milk": 100,
"coffee": 24,
},
"cost": 3.0,
}
}
resources = {
"water": 300,
"milk": 200,
"coffee": 100,
}
bank = 5.00
power = 'off'
QUART, DIME, NICK, PENN = 0.25, 0.10, 0.05, 0.01
def check():
return [resources['water'], resources['milk'], resources['coffee']]
def report():
print(f'''The coffee dispenser contains {resources['water']}ml of water,{resources['milk']}ml of milk,
{resources['coffee']}g of coffee with a balance of ${bank} in change''')
def pow():
global power
power = input("Would you like to (on/off) the system?").lower()
def refill():
report()
wa = int(input("How much water would you like to fill: "))
mk = int(input("How much milk would you like to add: "))
cf = int(input("How much coffee would you like to add: "))
resources['water'] += wa
resources['milk'] += mk
resources['coffee'] += cf
print(report())
var = True
while var:
print('######### COFFEE MACHINE#########\n'
'1)Power(1)\n'
'2)Print Report(2)\n'
'3)Add resources')
q = int(input())
if q == 1:
pow()
elif q == 2:
report()
elif q == 3:
refill()
while power == 'on':
ch = input("What would you like to drink(espresso/latte/cappuccino)\n").lower()
w, m, c = MENU[ch]['ingredients']['water'], MENU[ch]['ingredients']['milk'], MENU[ch]['ingredients']['coffee']
ing, ing1, cont = [w, m, c], ['water', 'milk', 'coffee'], "y"
res = check()
for i in range(0, 3):
if res[i] >= ing[i]:
print(f"Sufficient {ing1[i]} exists....")
resources[ing1[i]] -= ing[i]
else:
print("Sufficient {ing1[i]} doesn't exists. Please try again later")
cont = "n"
break
if cont != "y":
print("Sorry the problem will be sorted ASAP")
break
print(f"While the coffee is being made please provide ${MENU[ch]['cost']} for your {ch}")
q = int(input("How many quarters?")) * QUART
n = int(input("How many nickels?")) * NICK
d = int(input("How many dimes?")) * DIME
p = int(input("How many pennies?")) * PENN
net = q + n + d + p
balance = round(net - MENU[ch]['cost'], 2)
if balance > 0:
print(f"Please collect ${balance} as your balance")
bank += MENU[ch]['cost']
print("Please collect your drink")
elif balance < 0:
print("Sorry insufficient funds provided")
break
else:
print("Thanks for tendering exact change")
print("Please collect your drink")
print("Thanking for using our system. Going to hibernate until further actions")
pow()
var = not (input('Break the machine?(True/False)')).capitalize()