-
Notifications
You must be signed in to change notification settings - Fork 0
/
coffee_machine.py
159 lines (143 loc) · 5.26 KB
/
coffee_machine.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
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
#Coffee machine#
list = ["espresso", "latte", "cappuccino"]
# declaring global variable water ,milk ,coffee_beans #
water = 400
milk = 540
coffee_beans = 120
dispo_cup = 9
money = 550
# declaring remaining function #
def remaining():
status()
# declaring status function #
def status():
print("water " + str(water))
print("milk " + str(milk))
print("coffee_beans " + str(coffee_beans))
print("dispo_cup " + str(dispo_cup))
print("money " + str(money))
# declaring espresso coffee function #
def espresso():
global money
global water
global coffee_beans
global dispo_cup
num_cof = int(input("How many cups of coffee do you want?"))
wat_need = num_cof * 250
cof_bean_need = num_cof * 16
num_cup = num_cof * 1
price = num_cof * 4
if water >= wat_need and coffee_beans >= cof_bean_need and dispo_cup >= num_cup:
money = money + price
water = water - wat_need
coffee_beans = coffee_beans - cof_bean_need
dispo_cup = dispo_cup - num_cup
print("I have enough resource, making you a coffee")
print("you have to pay " + str(price)+"$") # this line#
elif water <= wat_need and coffee_beans >= cof_bean_need and dispo_cup >= num_cup:
print("sorry, not enough water!")
elif water >= wat_need and coffee_beans <= cof_bean_need and dispo_cup >= num_cup:
print("sorry, not enough coffee beans!")
elif water >= wat_need and coffee_beans >= cof_bean_need and dispo_cup <= num_cup:
print("sorry, not enough disposible cup!")
# declaring latte coffee function #
def latte():
global money
global water
global coffee_beans
global dispo_cup
num_cof = int(input("How many cups of coffee do you want?"))
wat_need = num_cof * 350
cof_bean_need = num_cof * 20
mil_need = num_cof * 75
price = num_cof * 7
num_cup = num_cof * 1
if water >= wat_need and coffee_beans >= cof_bean_need and milk >= mil_need and dispo_cup >= num_cup:
money += price
water -= wat_need
coffee_beans -= cof_bean_need
dispo_cup = dispo_cup - num_cup
print("I have enough resource, making you a coffee")
print("you have to pay "+str(price)+"$")
elif water <= wat_need and coffee_beans >= cof_bean_need and dispo_cup >= num_cup:
print("sorry, not enough water!")
elif water >= wat_need and coffee_beans <= cof_bean_need and dispo_cup >= num_cup:
print("sorry, not enough coffee beans!")
elif water >= wat_need and coffee_beans >= cof_bean_need and dispo_cup <= num_cup:
print("sorry, not enough disposible cup!")
# declaring cappuccino coffee function #
def cappuccino():
global money
global water
global coffee_beans
global dispo_cup
num_cof = int(input("How many cups of coffee do you want?"))
wat_need = num_cof * 200
cof_bean_need = num_cof * 12
mil_need = num_cof * 100
num_cup = num_cof * 1
price = num_cof * 6
if water >= wat_need and coffee_beans >= cof_bean_need and milk >= mil_need and dispo_cup >= num_cup:
money = money + price
water = water - wat_need
coffee_beans = coffee_beans - cof_bean_need
dispo_cup = dispo_cup - num_cup
print("I have enough resource, making you a coffee")
print("you have to pay "+str(price)+"$")
elif water <= wat_need and coffee_beans >= cof_bean_need and dispo_cup >= num_cup:
print("sorry, not enough water!")
elif water >= wat_need and coffee_beans <= cof_bean_need and dispo_cup >= num_cup:
print("sorry, not enough coffee beans!")
elif water >= wat_need and coffee_beans >= cof_bean_need and dispo_cup <= num_cup:
print("sorry, not enough disposible cup!")
def buy():
print("1 - espresso", "2 - latte", "3 - cappuccino")
cof_name = int(input("What you want from above coffee list ?"))
if cof_name == 1:
espresso()
elif cof_name == 2:
latte()
elif cof_name == 3:
cappuccino()
else:
print("Input is wrong")
def fill():
num_add_wat = int(input("How much ml of water do you want to add?"))
global water
water += num_add_wat
num_add_mil = int(input("How much ml of milk do you want to add?"))
global milk
milk += num_add_mil
num_add_cof_beans = int(input("How much grams of coffee beans do you want to add "))
global coffee_beans
coffee_beans += num_add_cof_beans
num_cup_of_fill = int(input("How much cup do you what to add ?"))
global dispo_cup
dispo_cup = num_cup_of_fill + dispo_cup
# i have to declera worker function which will help me to repeat the function again and again #
# giving option to user for buy, fill and take #
def main():
list2 = ["buy", "fill", "take", "remaining", "exit"]
print(list2)
option = input("what you want to do from above thing ?")
# for calling function exit #
if option == "exit":
quit()
# creating function remaining #
elif option == "remaining":
remaining()
main()
# creating function buy for user #
elif option == "buy":
buy()
main()
# It is for worker #
elif option == "fill":
fill()
main()
elif option == "take":
global money
print("I gave you " + str(money))
money -= money
main()
main()