Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
common inheritance solution in Clear category for 3 Chefs by tokyoamado
class AbstractCook:
def __init__(self):
self.food_price = 0
self.drink_price = 0
def add_food(self, food_amount, food_price):
self.food_price += food_amount * food_price
def add_drink(self, drink_amount, drink_price):
self.drink_price += drink_amount * drink_price
def total(self):
return '{}: {}, {}: {}, Total: {}'.format(
self.food_name, self.food_price,
self.drink_name, self.drink_price,
self.food_price + self.drink_price)
class JapaneseCook(AbstractCook):
def __init__(self):
super().__init__()
self.food_name = 'Sushi'
self.drink_name = 'Tea'
class RussianCook(AbstractCook):
def __init__(self):
super().__init__()
self.food_name = 'Dumplings'
self.drink_name = 'Compote'
class ItalianCook(AbstractCook):
def __init__(self):
super().__init__()
self.food_name = 'Pizza'
self.drink_name = 'Juice'
Dec. 22, 2019