From f18c94733dfd25453d850612fb25cc0a4e65761a Mon Sep 17 00:00:00 2001 From: Seniacat <82906147+Seniacat@users.noreply.github.com> Date: Tue, 20 Apr 2021 22:30:09 +0300 Subject: [PATCH 1/3] Create Pizzeria_oop --- Pizzeria_oop | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Pizzeria_oop diff --git a/Pizzeria_oop b/Pizzeria_oop new file mode 100644 index 0000000..6bf0c52 --- /dev/null +++ b/Pizzeria_oop @@ -0,0 +1,63 @@ +class Pizza: + pizza_size = {0: "SMALL", 1: "MEDIUM", 2: "LARGE"} + pizza_type = {"PEPPERONI": "Pepperoni", "MARGARITA": "Margarita"} + ready = {0: "COOKING", 1: "READY"} + def __init__(self, ingredients, size): + self.ingredients = ingredients + self.size = size + self.ready = Pizza.ready[0] + + def cook(self): setattr(self, 'ready', Pizza.ready[1]) + +class Pepperoni(Pizza): + ings = ['Salami', 'Cheese'] + def __init__(self, size): + super().__init__(Pepperoni.ings, size) + +class Margarita(Pizza): + ings = ['Tomato', 'Cheese'] + def __init__(self, size): + super().__init__(Margarita.ings, size) + +class Worker: + def __init__(self): + self.order = None + self._cash = 0 + + @staticmethod + def greet_client(name): print(f"Welcome, {name}!") + + def get_order(self, pizza_type, pizza_size): + if pizza_type == 'Pepperoni': + self.order = Pepperoni(pizza_size) + elif pizza_type == 'Margarita': + self. order = Margarita(pizza_size) + + def get_money(self, money): self._cash += money + + def process_order(self): + self.order.cook() + return self.order + +class Client: + client_name = 'Alex' + + def __init__(self, money, name=client_name,): + self._money = money + self.name = name + self.pizza = None + + @staticmethod + def choose_margarita_pizza(): return Pizza.pizza_type["MARGARITA"] + @staticmethod + def choose_pepperoni_pizza(): return Pizza.pizza_type["PEPPERONI"] + @staticmethod + def choose_small_size(): return Pizza.pizza_size[0] + @staticmethod + def choose_medium_size(): return Pizza.pizza_size[1] + @staticmethod + def choose_large_size(): return Pizza.pizza_size[2] + + def pay_money(self, money): self._money -= money + + def get_pizza(self, pizza): self.pizza = pizza From 419689f476c1dc41392849ff9e21c5f253b7c12b Mon Sep 17 00:00:00 2001 From: Seniacat <82906147+Seniacat@users.noreply.github.com> Date: Wed, 21 Apr 2021 17:14:06 +0300 Subject: [PATCH 2/3] Update Pizzeria_oop --- Pizzeria_oop | 79 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 24 deletions(-) diff --git a/Pizzeria_oop b/Pizzeria_oop index 6bf0c52..bd95495 100644 --- a/Pizzeria_oop +++ b/Pizzeria_oop @@ -1,63 +1,94 @@ class Pizza: - pizza_size = {0: "SMALL", 1: "MEDIUM", 2: "LARGE"} - pizza_type = {"PEPPERONI": "Pepperoni", "MARGARITA": "Margarita"} - ready = {0: "COOKING", 1: "READY"} + + SMALL = 25 + MEDIUM = 30 + LARGE = 40 + PEPPERONI = "Pepperoni type" + MARGARITA = "Margarita type" + COOKING = 0 + READY = 1 + def __init__(self, ingredients, size): self.ingredients = ingredients self.size = size - self.ready = Pizza.ready[0] - - def cook(self): setattr(self, 'ready', Pizza.ready[1]) + self.ready = Pizza.COOKING + + def cook(self): + print('Pizza is being cooked...') + self.ready = Pizza.READY + print('Pizza is ready!') + class Pepperoni(Pizza): - ings = ['Salami', 'Cheese'] + + pepperoni_ings = ['Salami', 'Cheese'] + def __init__(self, size): - super().__init__(Pepperoni.ings, size) + super().__init__(Pepperoni.pepperoni_ings, size) + class Margarita(Pizza): - ings = ['Tomato', 'Cheese'] + + margarita_ings = ['Tomato', 'Cheese'] + def __init__(self, size): - super().__init__(Margarita.ings, size) + super().__init__(Margarita.margarita_ings, size) + class Worker: + def __init__(self): self.order = None - self._cash = 0 + self.__cash = 0 @staticmethod - def greet_client(name): print(f"Welcome, {name}!") + def greet_client(name): + print(f"Welcome, {name}!") def get_order(self, pizza_type, pizza_size): - if pizza_type == 'Pepperoni': + if pizza_type == Pizza.PEPPERONI: self.order = Pepperoni(pizza_size) elif pizza_type == 'Margarita': self. order = Margarita(pizza_size) - def get_money(self, money): self._cash += money + def get_money(self, money): + self.__cash += money def process_order(self): self.order.cook() return self.order + class Client: - client_name = 'Alex' + default_name = 'Alex' - def __init__(self, money, name=client_name,): - self._money = money + def __init__(self, money, name=default_name): + self.__money = money self.name = name self.pizza = None @staticmethod - def choose_margarita_pizza(): return Pizza.pizza_type["MARGARITA"] + def choose_margarita_pizza(): + return Pizza.MARGARITA + @staticmethod - def choose_pepperoni_pizza(): return Pizza.pizza_type["PEPPERONI"] + def choose_pepperoni_pizza(): + return Pizza.PEPPERONI + @staticmethod - def choose_small_size(): return Pizza.pizza_size[0] + def choose_small_size(): + return Pizza.SMALL + @staticmethod - def choose_medium_size(): return Pizza.pizza_size[1] + def choose_medium_size(): + return Pizza.MEDIUM + @staticmethod - def choose_large_size(): return Pizza.pizza_size[2] + def choose_large_size(): + return Pizza.LARGE - def pay_money(self, money): self._money -= money + def pay_money(self, money): + self.__money -= money - def get_pizza(self, pizza): self.pizza = pizza + def get_pizza(self, pizza): + self.pizza = pizza From b114d2bb4dbfd3c11f899fcacf6decfba35e057c Mon Sep 17 00:00:00 2001 From: Seniacat <82906147+Seniacat@users.noreply.github.com> Date: Wed, 21 Apr 2021 17:17:12 +0300 Subject: [PATCH 3/3] Update Pizzeria_oop --- Pizzeria_oop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pizzeria_oop b/Pizzeria_oop index bd95495..f43c13e 100644 --- a/Pizzeria_oop +++ b/Pizzeria_oop @@ -48,7 +48,7 @@ class Worker: def get_order(self, pizza_type, pizza_size): if pizza_type == Pizza.PEPPERONI: self.order = Pepperoni(pizza_size) - elif pizza_type == 'Margarita': + elif pizza_type == Pizza.MARGARITA: self. order = Margarita(pizza_size) def get_money(self, money):