Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
All work performed in the Abstract factory solution in Clear category for 3 Chefs by kkkkk
class AbstractCook:
"""Abstract factory for different types of cooks."""
def __init__(self, food_type, drink_type):
self._food_type = food_type
self._drink_type = drink_type
self._food_total = 0
self._drink_total = 0
def add_food(self, food_amount, food_price):
"""Add food to client order."""
self._food_total += food_amount * food_price
def add_drink(self, drink_amount, drink_price):
"""Add drink to client order."""
self._drink_total += drink_amount * drink_price
def total(self):
"""Return string indicating food, drink and grand total."""
return (f'{self._food_type.capitalize()}: {self._food_total}, '
f'{self._drink_type.capitalize()}: {self._drink_total}, '
f'Total: {self._food_total + self._drink_total}')
class JapaneseCook(AbstractCook):
"""Japanese cook based on the abstract factory 'cook'."""
def __init__(self):
AbstractCook.__init__(self, "Sushi", "Tea")
class RussianCook(AbstractCook):
"""Russian cook based on the abstract factory 'cook'."""
def __init__(self):
AbstractCook.__init__(self, "Dumplings", "Compote")
class ItalianCook(AbstractCook):
"""Italian cook based on the abstract factory 'cook'."""
def __init__(self):
AbstractCook.__init__(self, "Pizza", "Juice")
April 9, 2020
Comments: