forked from dancergraham/HeadFirstDesignPatterns_python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbarista.py
47 lines (33 loc) · 951 Bytes
/
barista.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
class CaffeineBeverage:
def prepare_recipe(self):
self.boil_water()
self.brew()
self.pour_in_cup()
self.add_condiments()
def brew(self):
raise NotImplementedError
def add_condiments(self):
raise NotImplementedError
def boil_water(self):
print("Boiling water")
def pour_in_cup(self):
print("Pouring into cup")
class Tea(CaffeineBeverage):
def brew(self):
print("Steeping the tea")
def add_condiments(self):
print("Adding Lemon")
class Coffee(CaffeineBeverage):
def brew(self):
print("Dripping Coffee through filter")
def add_condiments(self):
print("Adding Sugar and Milk")
def beverage_test_drive():
tea = Tea()
coffee = Coffee()
print("\nMaking tea...")
tea.prepare_recipe()
print("\nMaking coffee...")
coffee.prepare_recipe()
if __name__ == "__main__":
beverage_test_drive()