Skip to content

Commit 2310dac

Browse files
committed
reparos no ABC MenuComponent e correções de flake8
1 parent 3321a63 commit 2310dac

File tree

3 files changed

+87
-86
lines changed

3 files changed

+87
-86
lines changed

composite/demo.py

Lines changed: 81 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -13,118 +13,119 @@
1313
all_menus.append(cafe_menu)
1414

1515
pancake_house_menu.append(MenuItem(
16-
"K&B's Pancake Breakfast",
17-
"Pancakes with scrambled eggs, and toast",
18-
True,
19-
2.99))
16+
"K&B's Pancake Breakfast",
17+
"Pancakes with scrambled eggs, and toast",
18+
True,
19+
2.99))
2020
pancake_house_menu.append(MenuItem(
21-
"Regular Pancake Breakfast",
22-
"Pancakes with fried eggs, sausage",
23-
False,
24-
2.99))
21+
"Regular Pancake Breakfast",
22+
"Pancakes with fried eggs, sausage",
23+
False,
24+
2.99))
2525
pancake_house_menu.append(MenuItem(
26-
"Blueberry Pancakes",
27-
"Pancakes made with fresh blueberries, and blueberry syrup",
28-
True,
29-
3.49))
26+
"Blueberry Pancakes",
27+
"Pancakes made with fresh blueberries, and blueberry syrup",
28+
True,
29+
3.49))
3030
pancake_house_menu.append(MenuItem(
31-
"Waffles",
32-
"Waffles, with your choice of blueberries or strawberries",
33-
True,
34-
3.59))
31+
"Waffles",
32+
"Waffles, with your choice of blueberries or strawberries",
33+
True,
34+
3.59))
3535

3636
diner_menu.append(MenuItem(
37-
"Vegetarian BLT",
38-
"(Fakin') Bacon with lettuce & tomato on whole wheat",
39-
True,
40-
2.99))
37+
"Vegetarian BLT",
38+
"(Fakin') Bacon with lettuce & tomato on whole wheat",
39+
True,
40+
2.99))
4141
diner_menu.append(MenuItem(
42-
"BLT",
43-
"Bacon with lettuce & tomato on whole wheat",
44-
False,
45-
2.99))
42+
"BLT",
43+
"Bacon with lettuce & tomato on whole wheat",
44+
False,
45+
2.99))
4646
diner_menu.append(MenuItem(
47-
"Soup of the day",
48-
"A bowl of the soup of the day, with a side of potato salad",
49-
False,
50-
3.29))
47+
"Soup of the day",
48+
"A bowl of the soup of the day, with a side of potato salad",
49+
False,
50+
3.29))
5151
diner_menu.append(MenuItem(
52-
"Hotdog",
53-
"A hot dog, with saurkraut, relish, onions, topped with cheese",
54-
False,
55-
3.05))
52+
"Hotdog",
53+
"A hot dog, with saurkraut, relish, onions, topped with cheese",
54+
False,
55+
3.05))
5656
diner_menu.append(MenuItem(
57-
"Steamed Veggies and Brown Rice",
58-
"Steamed vegetables over brown rice",
59-
True,
60-
3.99))
57+
"Steamed Veggies and Brown Rice",
58+
"Steamed vegetables over brown rice",
59+
True,
60+
3.99))
6161

6262
diner_menu.append(MenuItem(
63-
"Pasta",
64-
"Spaghetti with Marinara Sauce, and a slice of sourdough bread",
65-
True,
66-
3.89))
63+
"Pasta",
64+
"Spaghetti with Marinara Sauce, and a slice of sourdough bread",
65+
True,
66+
3.89))
6767

6868
diner_menu.append(dessert_menu)
6969

7070
dessert_menu.append(MenuItem(
71-
"Apple Pie",
72-
"Apple pie with a flakey crust, topped with vanilla icecream",
73-
True,
74-
1.59))
71+
"Apple Pie",
72+
"Apple pie with a flakey crust, topped with vanilla icecream",
73+
True,
74+
1.59))
7575

7676
dessert_menu.append(MenuItem(
77-
"Cheesecake",
78-
"Creamy New York cheesecake, with a chocolate graham crust",
79-
True,
80-
1.99))
77+
"Cheesecake",
78+
"Creamy New York cheesecake, with a chocolate graham crust",
79+
True,
80+
1.99))
8181
dessert_menu.append(MenuItem(
82-
"Sorbet",
83-
"A scoop of raspberry and a scoop of lime",
84-
True,
85-
1.89))
82+
"Sorbet",
83+
"A scoop of raspberry and a scoop of lime",
84+
True,
85+
1.89))
8686

8787
cafe_menu.append(MenuItem(
88-
"Veggie Burger and Air Fries",
89-
"Veggie burger on a whole wheat bun, lettuce, tomato, and fries",
90-
True,
91-
3.99))
88+
"Veggie Burger and Air Fries",
89+
"Veggie burger on a whole wheat bun, lettuce, tomato, and fries",
90+
True,
91+
3.99))
9292
cafe_menu.append(MenuItem(
93-
"Soup of the day",
94-
"A cup of the soup of the day, with a side salad",
95-
False,
96-
3.69))
93+
"Soup of the day",
94+
"A cup of the soup of the day, with a side salad",
95+
False,
96+
3.69))
9797
cafe_menu.append(MenuItem(
98-
"Burrito",
99-
"A large burrito, with whole pinto beans, salsa, guacamole",
100-
True,
101-
4.29))
98+
"Burrito",
99+
"A large burrito, with whole pinto beans, salsa, guacamole",
100+
True,
101+
4.29))
102102

103103
cafe_menu.append(coffee_menu)
104104

105105
coffee_menu.append(MenuItem(
106-
"Coffee Cake",
107-
"Crumbly cake topped with cinnamon and walnuts",
108-
True,
109-
1.59))
106+
"Coffee Cake",
107+
"Crumbly cake topped with cinnamon and walnuts",
108+
True,
109+
1.59))
110110
coffee_menu.append(MenuItem(
111-
"Bagel",
112-
"Flavors include sesame, poppyseed, cinnamon raisin, pumpkin",
113-
False,
114-
0.69))
111+
"Bagel",
112+
"Flavors include sesame, poppyseed, cinnamon raisin, pumpkin",
113+
False,
114+
0.69))
115115
coffee_menu.append(MenuItem(
116-
"Biscotti",
117-
"Three almond or hazelnut biscotti cookies",
118-
True,
119-
0.89))
116+
"Biscotti",
117+
"Three almond or hazelnut biscotti cookies",
118+
True,
119+
0.89))
120+
120121

121122
class Garconete:
122123

123-
def __init__(self, menu):
124-
self.menu = menu
124+
def __init__(self, menu):
125+
self.menu = menu
125126

126-
def display_menu(self):
127-
self.menu.display()
127+
def display_menu(self):
128+
self.menu.display()
128129

129130
jane = Garconete(all_menus)
130131

composite/menu.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from menuabc import MenuComponent
22

3+
34
class Menu(MenuComponent):
45

56
def __init__(self, name, description):
@@ -33,7 +34,7 @@ def display(self):
3334
if self.is_vegetarian:
3435
print(' (v)', end='')
3536
print(', ', self.description, sep='')
36-
print('-' * 60);
37+
print('-' * 60)
3738
for menu_component in self.menu_components:
3839
menu_component.display()
3940

@@ -67,4 +68,4 @@ def display(self):
6768
if self.is_vegetarian:
6869
print(' (v)', end='')
6970
print(',', self.price)
70-
print(' --', self.description);
71+
print(' --', self.description)

composite/menuabc.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
21
from abc import ABC, abstractmethod
32

3+
44
class MenuComponent(ABC):
55
'''Item do cardápio, com sub-itens'''
66

@@ -27,9 +27,9 @@ def description(self):
2727
'''obter descrição do item'''
2828

2929
@property
30-
@abstractmethod
31-
def description(self):
30+
def price(self):
3231
'''obter preço do item'''
32+
raise NotImplementedError()
3333

3434
@property
3535
@abstractmethod
@@ -39,4 +39,3 @@ def is_vegetarian(self):
3939
@abstractmethod
4040
def display(self):
4141
'''exibir item e sub-itens'''
42-

0 commit comments

Comments
 (0)