-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathfacade.py
51 lines (41 loc) · 1.09 KB
/
facade.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
'''
Facade design pattern
'''
class Cook(object):
'''
Facade class
Desc: Provides easy interface to prepare dish instead of calling three
different classes and making difficult for client to use.
'''
def prepareDish(self):
self.cutter = Cutter()
self.cutter.cutVegetables()
self.boiler = Boiler()
self.boiler.boilVegetables()
self.frier = Frier()
self.frier.fry()
class Cutter(object):
'''
System class
Desc: Cutter class provide feature of cutting vegetables
'''
def cutVegetables(self):
print("All vegetables are cut")
class Boiler(object):
'''
System class
Desc: Cutter class provide feature of boiling vegetables
'''
def boilVegetables(self):
print("All vegetables are boiled")
class Frier(object):
'''
System class
Desc: Cutter class provide feature of frying vegetables
'''
def fry(self):
print("All vegetables is mixed and fried.")
if __name__ == "__main__":
# Using facade class to prepare dish
cook = Cook()
cook.prepareDish()