-
Notifications
You must be signed in to change notification settings - Fork 0
/
factory.py
58 lines (39 loc) · 1 KB
/
factory.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
"""
Here we are implementing Pizza store.
Pizza Store has distributed pizza prepration in following set
1: Prepare
2: Bake
3: cut
4: Box
Pizza can be of any type, Cheese, double cheese, Vegeroma, Paneer
So, Customer comes to Pizza store and orders a pizza
"""
class Pizza:
def prepare(self):
print("preparing")
def bake(self):
print("baking")
def box(self):
print("wrapping")
class CheesPizza(Pizza):
pass
class PaneerPizaa(Pizza):
pass
class PizzaFactory:
def get_pizza(self, pizza_type):
if pizza_type == 'Cheese':
return CheesPizza()
elif pizza_type == 'Paneer':
return PaneerPizaa()
class PizzaStore:
pizza = None
def __init__(self):
self.factory = PizzaFactory()
def order_pizza(self, pizza_type):
self.pizza = self.factory.get_pizza(pizza_type)
def prepare(self):
self.pizza.prepare()
def bake(self):
self.pizza.bake()
def box(self):
self.pizza.box()