Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
One AbstractClass and 3 implementations solution in Clear category for 3 Chefs by swagg010164
from abc import ABC, abstractmethod
class AbstractCook(ABC):
def __init__(self, food=0, drink=0, total=0):
self.food = food
self.drink = drink
self.sum = total
def add_food(self, food_amount, food_price):
self.food += food_amount * food_price
self.sum += food_amount * food_price
def add_drink(self, drink_amount, drink_price):
self.drink += drink_amount * drink_price
self.sum += drink_amount * drink_price
@abstractmethod
def total(self):
raise NotImplementedError
class JapaneseCook(AbstractCook):
def total(self):
return f'Sushi: {self.food}, Tea: {self.drink}, Total: {self.sum}'
class RussianCook(AbstractCook):
def total(self):
return f'Dumplings: {self.food}, Compote: {self.drink}, Total: {self.sum}'
class ItalianCook(AbstractCook):
def total(self):
return f'Pizza: {self.food}, Juice: {self.drink}, Total: {self.sum}'
July 9, 2020
Comments: