Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
f-string solution in Clear category for 3 Chefs by Sioul
class AbstractCook:
def __init__(self, food, drink):
self.food = food
self.drink = drink
self.food_price = 0
self.drink_price = 0
def add_food(self, amount, price):
self.food_price += price * amount
def add_drink(self, amount, price):
self.drink_price += price * amount
def total(self):
return (f"{self.food}: {self.food_price}, "
f"{self.drink}: {self.drink_price}, "
f"Total: {self.food_price + self.drink_price}")
class JapaneseCook(AbstractCook):
def __init__(self):
super().__init__("Sushi", "Tea")
class RussianCook(AbstractCook):
def __init__(self):
super().__init__("Dumplings", "Compote")
class ItalianCook(AbstractCook):
def __init__(self):
super().__init__("Pizza", "Juice")
Oct. 9, 2019