-
Notifications
You must be signed in to change notification settings - Fork 0
/
ingredients.py
94 lines (70 loc) · 1.98 KB
/
ingredients.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
# class Plate:
# def __init__(self, location):
# self.name = 'Plate'
# self.contains = None
# self.location = location
# def __str__(self):
# return self.name
# def __eq__(self, other):
# return self.name == other.name
# def move_to(self, location):
# self.location = location
class Ingredient:
def __init__(self, name, location):
self.name = name
self.location = location
self.holded = False
self.chopped = False
self.grilled = False
def __str__(self):
prefix = "Fresh"
if self.chopped:
prefix = "Chopped"
if self.grilled:
prefix = "Grilled"
if prefix:
return f"{prefix} {self.name}"
else:
return self.name
def __eq__(self, other):
return str(self) == str(other)
def move_to(self, location):
self.location = location
def grill(self):
pass
def chop(self):
pass
def is_grillable(self):
return False
def is_choppable(self):
return False
class Bread(Ingredient):
def __init__(self, location):
super().__init__('Bread', location)
class Pork(Ingredient):
def __init__(self, location):
super().__init__('Pork', location)
def grill(self):
self.grilled = True
return self
def is_grillable(self):
return True
class Cheese(Ingredient):
def __init__(self, location):
super().__init__('Cheese', location)
class Lettuce(Ingredient):
def __init__(self, location):
super().__init__('Lettuce', location)
def chop(self):
self.chopped = True
return self
def is_choppable(self):
return True
class Tomato(Ingredient):
def __init__(self, location):
super().__init__('Tomato', location)
def chop(self):
self.chopped = True
return self
def is_choppable(self):
return True