-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstage5.py
93 lines (71 loc) · 2.18 KB
/
stage5.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# supply variables
stored_money = 550
stored_water = 400
stored_milk = 540
stored_beans = 120
stored_cups = 9
def prompt():
print("The coffee machine has:")
print(f"{stored_water} of water")
print(f"{stored_milk} of milk")
print(f"{stored_beans} of coffee beans")
print(f"{stored_cups} of disposable cups")
print(f"{stored_money} of money")
print()
def update_storage_info(money, water, milk, beans):
global stored_money
global stored_water
global stored_milk
global stored_beans
global stored_cups
stored_money = stored_money + money
stored_water = stored_water - water
stored_milk = stored_milk - milk
stored_beans = stored_beans - beans
stored_cups = stored_cups - 1
def refill(water, milk, beans, cups):
global stored_water
global stored_milk
global stored_beans
global stored_cups
stored_water = stored_water + water
stored_milk = stored_milk + milk
stored_beans = stored_beans + beans
stored_cups = stored_cups + cups
def fill():
water = int(input("Write how many ml of water do you want to add:\n"))
milk = int(input("Write how many ml of milk do you want to add:\n"))
beans = int(input("Write how many grams of coffee beans do you want to add\n"))
cups = int(input("Write how many disposable cups of coffee do you want to add:\n"))
refill(water, milk, beans, cups)
def types_of_coffee():
coffee_flavor = int(
input("What do you want to buy? 1" " - espresso, 2 - latte, 3 - cappuccino:\n")
)
if coffee_flavor == 1:
update_storage_info(money=4, water=250, milk=0, beans=16)
elif coffee_flavor == 2:
update_storage_info(money=7, water=350, milk=75, beans=20)
elif coffee_flavor == 3:
update_storage_info(money=6, water=200, milk=100, beans=12)
def take():
global stored_money
cash = stored_money
stored_money = 0
print(f"I gave you ${cash}")
# first prompt
prompt()
# second prompt
answer = input("Write action (buy, fill, take):\n")
if answer == "buy":
types_of_coffee()
print()
prompt()
elif answer == "fill":
fill()
print()
prompt()
elif answer == "take":
take()
print()
prompt()