1
- # 6. Create a Sandwich class with the attributes order_number and ingredients (which is given as a list).
2
- # - Only the ingredients will be given as input.
1
+ # 6. Create a Sandwich class with the attributes order_number and ingredients.
2
+ # - i. The ingredients attributes is given as a list - (Note: use list(<atrribute>) to enable this).
3
+ # - Only the ingredients attributes will be given as input.
4
+ # - ii. The order attriubte will be a method that counts the order number.
5
+ # - iii. Make three methods for the following favourite sandwiches, for customers who don't want to create a sandwich:
6
+ # - vegan_hot - vegan cheese, meatless meatballs, jalapenos
7
+ # - meat_feast - steak, peppers, cheese
8
+ # - veggie - tomamto, spinach, mushroom, eggs
3
9
4
- # You should also make it possible to choose a ready-made sandwich rather than typing out the ingredients manually. Also hard-code the following sandwich flavours.
10
+ class Sandwich :
11
+ orders = 0
5
12
6
- # Name Ingredients
7
- # vegan_hot vegan cheese, meatless meatballs, jalapenos
8
- # meat_festival steak, peppers, cheese
9
- # garden_feast spinach, olives, mushroom, eggs
13
+ def __init__ (self , ingredients ):
14
+ self .ingredients = list (ingredients )
15
+ self .order_number = self .get_order_number ()
16
+
17
+ def get_order_number (self ):
18
+ Sandwich .orders += 1
19
+ return Sandwich .orders
20
+
21
+ def vegan_hot ():
22
+ return Sandwich (["vegan cheese" , "meatless meatballs" , "jalapenos" ])
23
+
24
+ def meat_feast ():
25
+ return Sandwich (["steak" , "peppers" , "cheese" ])
26
+
27
+ def veggie ():
28
+ return Sandwich (["tomato" , "spinach" , "mushroom" , "eggs" ])
29
+
30
+
31
+ sandwich1 = Sandwich .vegan_hot ()
32
+ print (sandwich1 .ingredients )
33
+ print (sandwich1 .order_number )
34
+ sandwich2 = Sandwich (["tuna" , "mayo" , "lettuce" ])
35
+ print (sandwich2 .ingredients )
36
+ print (sandwich2 .order_number )
0 commit comments