-
-
Save codecademydev/4eaba3156e7f5f1fc0d6a3db0eae5ec1 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 self.name + ' menu is available from ' + str(self.start_time) + ' - ' + str(self.end_time) + "." | |
def calculate_bill(self, purchased_items): | |
bill = 0 | |
for item in purchased_items: | |
if item in self.items: | |
bill += self.items[item] | |
return bill | |
# self.purchased_items = [] | |
# BRUNCH | |
brunch_items= { | |
'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 = Menu('Brunch', brunch_items, 1100, 1600) | |
# EARLY-BIRD | |
early_items= { | |
'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_menu = Menu('Early-Bird', early_items, 1500, 1800) | |
# DINNER | |
dinner_items= { | |
'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 = Menu('Dinner', dinner_items, 1700, 2300) | |
# KIDS | |
kids_items= { | |
'chicken nuggets': 6.50, 'fusilli with wild mushrooms': 12.00, 'apple juice': 3.00 | |
} | |
kids_menu = Menu('Kids', kids_items, 1100, 2100) | |
# print(brunch_menu.calculate_bill(['pancakes', 'home fries', 'coffee'])) | |
# print(early_menu.calculate_bill(['salumeria plate', 'vegan mushroom ravioli'])) | |
class Franchise: | |
def __init__(self, address, menus): | |
self.address = address | |
self.menus = menus | |
def __repr__(self): | |
return 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 | |
menus = [brunch_menu, early_menu, dinner_menu, kids_menu] | |
flagship_store = Franchise('1232 West End Road', menus) | |
new_installment = Franchise('12 East Mulberry Street', menus) | |
# print(flagship_store.available_menus(1700)) | |
class Business: | |
def __init__(self, name, franchises): | |
self.name = name | |
self.franchises = franchises | |
basta = Business("Basta Fazoolin' with my Heart", [flagship_store, new_installment]) | |
arepa_items = { | |
'arepa pabellon': 7.00, 'pernil arepa': 8.50, 'guayanes arepa': 8.00, 'jamon arepa': 7.50 | |
} | |
arepa_menu = Menu('Take a’ Arepa', arepa_items, 1000, 2000) | |
arepas_place = Franchise('189 Fitzgerald Avenue', arepa_menu) | |
arepa = Business('Take a\' Arepa', [flagship_store, new_installment]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment