-
Notifications
You must be signed in to change notification settings - Fork 0
/
CockatilApp.py
232 lines (135 loc) · 6.7 KB
/
CockatilApp.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
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
class Cocktail: #class for creating cocktails
def __init__(self, name, ingredients):
self.name = name
self.ingredients = ingredients
def cockatil_Info(self): #get information about specific cocktail
print(self.name.title().strip(),":")
for liquor in self.ingredients:
print(" -",liquor.title().strip())
def __str__(self):
return "{} | {}\n".format(self.name, self.ingredients)
JuiceVodka = Cocktail("Juice Vodka",["Orange Juice","Vodka"])
GinTonic = Cocktail("Gin Tonic",["Gin","Tonic"])
RumCola = Cocktail("Rum Cola",["Rum","Coca Cola"])
WhiskyCola = Cocktail("Whisky Cola",["Whisky", "Coca Cola"])
#___________________________________________________________________________________
class Cocktail_Bar: #class for cocktail bars
def __init__ (self, name):
self.barthender = []
self.name = name
self.drinks = ["Vodka", "Gin", "Rum", "Tequila", "Whisky", "Curracao blue", "Beer",
"Amaretto", "Triple Sec", "Coca Cola", "Fanta", "Sprite", "Red Bull", "Tonic",
"Orange Juice", "Blueberry Juice","Grenadine", "Pineapple Juice", "Lemon Juice"]
self.cocktails = [JuiceVodka, GinTonic, RumCola, WhiskyCola]
def all_cocktails(self): #show all cocktails that bar has
i = 0
print(len(self.cocktails), "different cocktails.")
for cocktail in self.cocktails:
i+=1
print("\n", i,")", cocktail.name)
for liquor in cocktail.ingredients:
print(" -", liquor)
def get_cocktail(self, name): #get specific cocktail
name = name.strip().lower()
for cocktail in self.cocktails:
if cocktail.name.lower() == name:
print("\n",cocktail.name)
for liquor in cocktail.ingredients:
print(" -", liquor)
break
else:
print("There is no cocktail named", name.title())
def cocktail_Names(self): # show names of all cocktails
i = 0
print(len(self.cocktails), "different cocktails.\n")
for cocktail in self.cocktails:
i+=1
print( i,")", cocktail.name)
def all_needed_ingredients(self): # show all ingredients for all cocktails
all_needed_drinks = []
for cocktail in self.cocktails:
for liquor in cocktail.ingredients:
if liquor.lower() not in all_needed_drinks:
all_needed_drinks.append(liquor.lower())
print("You need",len(all_needed_drinks),"different drinks for all cocktails.\n")
i=0
for drink in all_needed_drinks:
i += 1
print(i, ")", drink.strip().title())
def add_new_cocktail(self, name, drinks): #add new cocktail to bar menu
name = name.lower().strip()
cocktail_dinks = []
for cocktail in self.cocktails:
if cocktail.name.lower()==name:
print("Cocktail",name.title(),"already in list")
else:
for drink in drinks:
cocktail_dinks.append(drink.strip().title())
new_cocktail = Cocktail(name.strip().title(), cocktail_dinks)
self.cocktails.append(new_cocktail)
print("Cocktail named",new_cocktail.name,"added!\n")
break
def delete_Cocktail(self, name): #delete specific cocktail
for cocktail in self.cocktails:
if cocktail.name.lower()== name.lower().strip():
self.cocktails.remove(cocktail)
print("Cocktail",name.title(),"deleted!\n")
break
else:
print("There is no cocktail named", name.title(),"!")
def shopping(self): #show what ingredients you need to buy so that you can make all cocktails
Needed_Drinks = []
for cocktail in self.cocktails:
for liquor in cocktail.ingredients:
if liquor.strip().lower() not in Needed_Drinks:
Needed_Drinks.append(liquor.strip().lower())
Bar_Drinks = []
for drink in self.drinks:
Bar_Drinks.append(drink.strip().lower())
missing_drinks = set(Needed_Drinks) - set(Bar_Drinks)
if len(missing_drinks) != 0:
print("\nYou need to buy:")
for drink in missing_drinks:
print(" -", drink.strip().title())
else:
print("\nYou have all drinks!")
def search_by_liquor(self, drinks): #show cocktails that has specific liquor
print("\nCocktails that have specific liquor/s:")
i=0
for cocktail in self.cocktails:
for drink in drinks:
if drink.lower() in (liquor.lower() for liquor in cocktail.ingredients):
i+=1
print("\n", i,")", cocktail.name.title(), "\n")
for cocktail_ingredients in cocktail.ingredients:
print(" -",cocktail_ingredients.title())
def what_can_i_make(self, all_drinks): #enter list of ingredients and see what coctails can you make
all_drinks_set = set()
for item in all_drinks:
all_drinks_set.add(item.strip().lower())
print("\nAvailable cocktails:")
i=0
for cocktail in self.cocktails:
new_cocktail = set(drink.strip().lower() for drink in cocktail.ingredients)
if new_cocktail.intersection(all_drinks_set) == new_cocktail:
i+=1
cocktail_Name = str(cocktail.name.strip().title())
print("\n",i,")", cocktail_Name,"\n")
for cocktail_ingredients in cocktail.ingredients:
print(" -",cocktail_ingredients.strip().title())
else:
print("No available cocktails!")
myBar = Cocktail_Bar("My Tropical Bar")
#myBar.all_cocktails()
#myBar.get_cocktail("Juice vottdka")
#myBar.cocktail_Names()
#myBar.all_needed_ingredients()
#myBar.add_new_cocktail("Taga",["Pelinkovac ", " coca cola"])
#myBar.all_cocktails()
#myBar.all_needed_ingredients()
#myBar.delete_Cocktail("Gin Tonic")
#myBar.all_cocktails()
#myBar.all_needed_ingredients()
#myBar.search_by_liquor(["gin","coca cola"])
#myBar.what_can_i_make(["tonic","rum"])
#myBar.shopping()