Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created April 4, 2021 13:31
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/e44b3c05693932be5ef8d48569e2791d to your computer and use it in GitHub Desktop.
Save codecademydev/e44b3c05693932be5ef8d48569e2791d to your computer and use it in GitHub Desktop.
Codecademy export
class Franchise:
def __init__(self, address, menus):
self.address = address
self.menus = menus
def __repr__(self):
repr("The address of this location is " + 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)
return available_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 repr(self.name + " is available from " + str(self.start_time) + " to " + str(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
class Business:
def __init__(self, name, franchises):
self.name = name
self.franchises = franchises
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, 1100, 1600)
eb_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", eb_menu, 1500, 1800)
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, 1700, 2300)
kids_menu = {
'chicken nuggets': 6.50, 'fusilli with wild mushrooms': 12.00, 'apple juice': 3.00
}
kids = Menu("Kids", kids_menu, 1100, 2100)
arepa_menu = {
'arepa pabellon': 7.00, 'pernil arepa': 8.50, 'guayanes arepa': 8.00, 'jamon arepa': 7.50
}
arepa = Menu("Take a/' Arepa", arepa_menu, 1000, 2000)
menus = [brunch, early_bird, dinner, kids]
# print(brunch)
# print(brunch.calculate_bill(['pancakes', 'home fries', 'coffee']))
# print(early_bird.calculate_bill(['salumeria plate', 'mushroom ravioli (vegan)']))
flagship_store = Franchise("1232 West End Road", menus)
new_installment = Franchise("12 East Mulberry Street", menus)
arepas_place = Franchise("189 Fitzgerald Avenue", arepa)
# print(flagship_store.available_menus(1700))
biz1 = Business("Basta Fazoolin/' with my Heart", [flagship_store, new_installation])
biz2 = Business("Take a/' Arepa", arepas_place)
@chrislee0101
Copy link

Here is my finished code for Basta Fazoolin. Any commnets or suggestions are appreciated.

@chrislee0101
Copy link

Caught a typo bug just after posting. In my first business I call new_installation, should be new_installment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment