Предмет:
ИнформатикаАвтор:
luiscooperОтвет:
from abc import ABC, abstractmethod
class Dish(ABC):
@abstractmethod
def get_description(self):
pass
@abstractmethod
def get_price(self):
pass
class Starter(Dish):
def __init__(self, description, price):
self.description = description
self.price = price
def get_description(self):
return self.description
def get_price(self):
return self.price
class MainCourse(Dish):
def __init__(self, description, price):
self.description = description
self.price = price
def get_description(self):
return self.description
def get_price(self):
return self.price
class Dessert(Dish):
def __init__(self, description, price):
self.description = description
self.price = price
def get_description(self):
return self.description
def get_price(self):
return self.price
class Order(ABC):
@abstractmethod
def add_dish(self, dish):
pass
@abstractmethod
def remove_dish(self, dish):
pass
@abstractmethod
def calculate_total(self):
pass
class TableOrder(Order):
def __init__(self):
self.dishes = []
def add_dish(self, dish):
self.dishes.append(dish)
def remove_dish(self, dish):
self.dishes.remove(dish)
def calculate_total(self):
total = 0
for dish in self.dishes:
total += dish.get_price()
return total
class DeliveryOrder(Order):
def __init__(self):
self.dishes = []
def add_dish(self, dish):
self.dishes.append(dish)
def remove_dish(self, dish):
self.dishes.remove(dish)
def calculate_total(self):
total = 0
for dish in self.dishes:
total += dish.get_price()
return total
Объяснение:
Автор:
brandon163Добавить свой ответ
Предмет:
ИнформатикаАвтор:
juliannacastroОтветов:
Смотреть