Hi! Sorry, I’m new here so I might be asking something I should ask somewhere else… Anyway, I have a problem with “Basta Frazoolin’” project as well: I get an unexpected “None” in the output, and I can’t understand why… can anyone help me?
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 calculate_bill(self, purchased_items):
self.purchased_items = purchased_items
bill = 0
for item in self.purchased_items:
if item in self.items:
bill += self.items[item]
else:
return "You selected an item that is not in our menu."
return "Bill: ${}".format(bill)
def __repr__(self):
return "The \"{name}\" menu is available from {start_hour} to {end_hour}.".format(name=self.name, start_hour=self.start_time, end_hour=self.end_time)
brunch = Menu("Brunch", {'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}, 11, 16)
early_bird = Menu("Early Bird", {'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}, 15, 18)
dinner = Menu("Dinner", {'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}, 17, 23)
kids = Menu("Kids", {'chicken nuggets': 6.50, 'fusilli with wild mushrooms': 12.00, 'apple juice': 3.00}, 11, 21)
class Franchise(Menu):
def __init__(self, address, menus):
self.address = address
self.menus = menus
def available_menus(self, time):
for menu in self.menus:
if time in range(menu.start_time, menu.end_time):
print("Order an item from the \"{}\" menu:".format(menu.name))
for plate in menu.items.keys():
print(" {} ${}".format(plate, menu.items[plate]))
if time not in range(11, 23):
print("The restaurant is closed")
def __repr__(self):
return "The restaurant is located in: {}.".format(self.address)
flagship_store = Franchise("1232 West End Road", [brunch, early_bird, dinner, kids])
new_installment = Franchise("12 East Mulberry Street", [brunch, early_bird, dinner, kids])
print(flagship_store.available_menus(17))
The output is a list of food per menu with price, but followed by “None”.