Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created March 2, 2021 17:59
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/d46a0cb92668f834bf0c0dc5d4156467 to your computer and use it in GitHub Desktop.
Save codecademydev/d46a0cb92668f834bf0c0dc5d4156467 to your computer and use it in GitHub Desktop.
Codecademy export
#defining menu class
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 f'{self.name} menu is served from {self.start_time} to {self.end_time}.'
def calculate_bill(self, purchased_items):
total = 0
order = []
for items in purchased_items:
total += self.items[items]
order.append(items)
return f'Your total comes to £{total} for {order}.'
#instantiating menu
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)
#print(brunch.calculate_bill(['pancakes', 'home fries', 'coffee']))
#print(early_bird.calculate_bill(['salumeria plate', 'mushroom ravioli (vegan)']))
#creating franchise
class Franchise:
def __init__(self, address, menus):
self.address = address
self.menus = menus
def __repr__(self):
return f'{self.address}'
def available_menus(self, time):
available_menus = []
for menu in self.menus:
if time >= menu.start_time and time <= menu.end_time:
available_menus.append(menu.name)
return f'You can choose from {available_menus}'
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))
#print(flagship_store.menus)
#creating business
class Business:
def __init__(self, name, franchises):
self.name = name
self.franchise = franchises
first_business = Business("Basta Fazoolin' with my Heart", [flagship_store, new_installment])
arepas_menu = Menu('Take a’ Arepa',
{
'arepa pabellon': 7.00, 'pernil arepa': 8.50, 'guayanes arepa': 8.00, 'jamon arepa': 7.50
}, 10, 20)
arepas_place = Franchise('189 Fitzgerald Avenue', arepas_menu)
arepa_bus = Business('Take a\' Arepa', arepas_place)
print(arepa_bus.name)
print(arepa_bus.franchise)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment