Hello!
I’m having trouble with my Baasta Fazoolin Project. I’m stuck in the 16th checkmark where you need to create an available_menus function inside the Franchise class.
The loop is created and all I have to do is append the menus that occur within the time slot given in the parameters of the function.
Here’s how my code looks like…
# Making the Menus
class Menu:
def __init__(self, name, items, start_time, end_time):
self.name = name
self.items = items
self.start_time = start_time
self.end_time = end_time
def __repr__(self):
return "{} menu available from {} to {}".format(self.name, self.start_time, self.end_time)
def calculate_bill(self, purchased_items):
tot = 0
for item in purchased_items:
if item in self.items:
tot += self.items[item]
return tot
brunch_menu = {
'pancakes': 7.50, 'waffles': 9.00, 'burger': 11.00, 'home fries': 4.50, 'coffee': 1.50, 'espresso': 3.00, 'tea': 1.00, 'mimosa': 10.50, 'orange juice': 3.50
}
brunch = Menu("Brunch", brunch_menu, 11, 16)
early_bird_menu = {
'salumeria plate': 8.00, 'salad and breadsticks (serves 2, no refills)': 14.00, 'pizza with quattro formaggi': 9.00, 'duck ragu': 17.50, 'mushroom ravioli (vegan)': 13.50, 'coffee': 1.50, 'espresso': 3.00,
}
early_bird = Menu("Early Bird Menu", early_bird_menu, 15, 18)
dinner_menu = {
'crostini with eggplant caponata': 13.00, 'ceaser salad': 16.00, 'pizza with quattro formaggi': 11.00, 'duck ragu': 19.50, 'mushroom ravioli (vegan)': 13.50, 'coffee': 2.00, 'espresso': 3.00,
}
dinner = Menu("Dinner", dinner_menu, 17, 23)
kids_menu = {
'chicken nuggets': 6.50, 'fusilli with wild mushrooms': 12.00, 'apple juice': 3.00
}
kids = Menu("Kids Menu", kids_menu, 11, 21)
menus = [brunch_menu, early_bird_menu, dinner_menu, kids_menu]
# print(brunch)
bill1 = brunch.calculate_bill(['pancakes', 'home fries', 'coffee'])
# print(bill1)
bill2 = early_bird.calculate_bill(['salumeria plate', 'mushroom ravioli (vegan)'])
# print(bill2)
# Creating the Franchises
class Franchise:
def __init__(self, address, menus):
self.address = address
self.menus = menus
def __repr__(self):
return self.address
def available_menus(self, time):
self.time = time
available_menus = []
for self.menu in self.menus:
if time>=self.menu.start_time and time<=self.menu.end_time:
available_menus.append(self.menu)
return available_menus
flagship_store = Franchise("1232 West End Road", menus)
new_installment = Franchise("12 East Mulberry Street", menus)
flagship_store.available_menus(12)
Unfortunately, my interpreter is reading the menu as a dictionary by observing from the following error prompt.
Help would be appreciated!
Link to the exercise