Найти - Пользователи
Полная версия: Помогите проверить и исправить задачу
Начало » Центр помощи » Помогите проверить и исправить задачу
1
EnteX
Пиццерия предлагает пиццу в день для бизнес-ланча. Тип пиццы дня
зависит от дня недели. Наличие пиццы в день упрощает заказы на
клиентов. Им не обязательно быть специалистами по конкретным видам пиццы. Кроме того, клиенты могут
добавьте дополнительные ингредиенты в пиццу в день. Напишите программу, которая будет формировать заказы от
клиентов.

 class Pizza:
    def getIngredients(self):
         return self.ingredients
    def getExtraIngredients(self):
        return self.extra_ingredients
    def getTotalCost(self):
         return self.cost
    def __str__(self):
         return 'Ingredients: ' + str(self.getIngredients) + '\n' + 'Extra Ingredients: ' + str(self.getExtraIngredients()) + '\n' + 'Cost: ' + str(self.getTotalCost())
# Concrete Component.
class Marinara(Pizza):
    ingredients = ['tomatoes', 'basil leaves', 'garlic', 'oregano', 'olive oil' ]
    extra_ingredients = []
    cost = 44.0
# Concrete Component.
class Margherita(Pizza):
    ingredients = ['tomatoes in juice', 'garlic', 'olive oil', 'basil leaves','mozzarella']
    extra_ingredients = []
    cost = 35.0
# Concrete Component.
class Romana(Pizza):
    ingredients = ['mozzarella', 'basil leaves', 'canned tomatoes', 'capers','anchovies in oil', 'olive oil']
    extra_ingredients = []
    cost = 55.0
# Concrete Component.
class Pslowly(Pizza):
    ingredients = ['mozzarella']
    extra_ingredients = []
    cost = 5.0
# Concrete Component.
class Pslow(Pizza):
    ingredients = ['mozzarella', 'basil leaves']
    extra_ingredients = []
    cost = 10.0
# Concrete Component.
class Pnoraml(Pizza):
    ingredients = ['mozzarella', 'basil leaves', 'canned tomatoes']
    extra_ingredients = []
    cost = 15.0
# Concrete Component.
class Pmedium(Pizza):
    ingredients = ['mozzarella', 'basil leaves', 'canned tomatoes', 'capers']
    extra_ingredients = []
    cost = 20.0
# Decorator.
class Decorator(Pizza):
    def __init__(self, pizza_component):
        self.component = pizza_component
    def getIngredients(self):
        return self.component.getIngredients
    def getExtraIngredients(self):
        return self.component.getExtraIngredients() + Pizza.getExtraIngredients(self)
    def getTotalCost(self):
        return self.component.getTotalCost() + Pizza.getTotalCost(self)
# Concrete Decorator.
class Pepper(Decorator):
    cost = 10
    extra_ingredients = ['pepper']
    def __init__(self, pizza_component):
        Decorator.__init__(self, pizza_component)
# Concrete Decorator.
class Pineapple(Decorator):
    cost = 13
    extra_ingredients = ['pineapple']
    def __init__(self, pizza_component):
        Decorator.__init__(self, pizza_component)
def dayNameFromWeekday(weekday):
    days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
    return days[weekday]
    #print("Enter number weekday: ")
    #wd = int(input("num_day = "))
    #print(dayNameFromWeekday(int(wd)))
         if wd == 1:
    margherita = Marinara()
    if wd == 2:
    margherita = Margherita()
    if wd == 3:
    margherita = Romana()
    if wd == 4:
    margherita = Pslowly()
    if wd == 5:
    margherita = Pslow()
    if wd == 6:
    margherita = Pnoraml()
    if wd == 7:
    margherita = Pmedium()
   
#margherita = Margherita()
#margherita = Pineapple(Pepper(Margherita()))
print(dayNameFromWeekday(int(wd)))
print(Pepper(Margherita))

FishHook
EnteX
И ваш вопрос, разумеется, заключается в том что?…..
EnteX
FishHook
EnteXИ ваш вопрос, разумеется, заключается в том что?…..
Выдает ошибку
  File "E:/Project Python/4_2.py", line 82
    margherita = Marinara()
             ^
IndentationError: expected an indented block
В чем причина???
Evgen_irk
Где-то выше неправильные отступы
 def dayNameFromWeekday(weekday):
    days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
    return days[weekday]
    #print("Enter number weekday: ")
    #wd = int(input("num_day = "))
    #print(dayNameFromWeekday(int(wd)))
         if wd == 1:
    margherita = Marinara()
    if wd == 2:
    margherita = Margherita()
    if wd == 3:
    margherita = Romana()
    if wd == 4:
    margherita = Pslowly()
    if wd == 5:
    margherita = Pslow()
    if wd == 6:
    margherita = Pnoraml()
    if wd == 7:
    margherita = Pmedium()
После
 return days[weekday]
остальной код не выполняется
FishHook
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB