Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created February 18, 2021 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/eb55af418d337e33f739dbdffaf65a83 to your computer and use it in GitHub Desktop.
Save codecademydev/eb55af418d337e33f739dbdffaf65a83 to your computer and use it in GitHub Desktop.
Codecademy export
class Menu:
pass
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 "{name} menu available from {start_time} to {end_time}".format(name=self.name, start_time=self.start_time, end_time=self.end_time)
def calculate_bill(self, purchased_items):
bill = 0
for purchased_item in purchased_items:
if purchased_item in self.items:
bill += self.items[purchased_item]
return bill
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", 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", kids_menu, 11, 21)
print(brunch.calculate_bill(['pancakes', 'home fries', 'coffee']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment