-
Notifications
You must be signed in to change notification settings - Fork 1
/
Menu.py
54 lines (32 loc) · 1.29 KB
/
Menu.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
from Menu_Analyzer import *
class Menu:
### would return the Str representation of the names of the Dishes in a menu Text file.
def getDishNamesListFromTxt(menuTextStr):
return menuTextStr.split(",")
### reads a .txt file and returns a String.
def getStrFromTextFile(filePath):
textFile = open(filePath)
menuString = textFile.read()
#print(menuString)
return menuString
def __init__(self, menuString):
print("Constructing Menu.")
#print("BEFORE Simplifying\n"+str(menuString)+"\n")
self.menuString = simplifyMenu(menuString)
#print(str(self.menuString))
self.dishes = createDishList(self.menuString)
def __str__(self):
return str(self.dishes);
def __repr__(self):
return str(self.dishes);
def printIngredients(self):
for dish in self.dishes:
print(dish.dishName)
print(dish.ingredients)
def getDish(self, name):
name = str(name)
for dish in self.dishes:
if(dish.dishName.strip().lower() == name.strip().lower()):
return dish
print("Dish not found!")
return -1