Skip to content

Commit bee0b56

Browse files
Create OOPs.py
1 parent eff0aa9 commit bee0b56

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

OOPs.py

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Creating Menu System Class
2+
3+
class Menu:
4+
def __init__(self, name, items, start_time, end_time):
5+
self.name = name
6+
self.items = items
7+
self.start_time = start_time
8+
self.end_time = end_time
9+
10+
def __repr__(self):
11+
return "Name of The Menu: {},\nAvailable from: {}'o clock to {}'o clock".format(self.name, self.start_time, self.end_time)
12+
13+
def calculate_bill(self, purchased_items):
14+
bill = 0
15+
for each in self.items:
16+
for food in purchased_items:
17+
if food == each:
18+
bill += self.items[food]
19+
return bill
20+
21+
# Menu Objects
22+
brunch = Menu("brunch", {
23+
'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
24+
}, 11, 16)
25+
26+
27+
early_bird = Menu("Early Bird", {
28+
'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,
29+
}, 15, 18)
30+
31+
32+
dinner = Menu("dinner",{
33+
'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,
34+
}, 17, 23)
35+
36+
37+
kids = Menu("dinner",{
38+
'chicken nuggets': 6.50, 'fusilli with wild mushrooms': 12.00, 'apple juice': 3.00
39+
}, 11, 21)
40+
41+
42+
# Testing Instance
43+
print(brunch.calculate_bill(['pancakes', 'home fries', 'coffee']))
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
# Franchaise System
55+
56+
class Franchise:
57+
def __init__(self, address, menus):
58+
self.address = address
59+
self.menus = menus
60+
61+
62+
def __repr__(self):
63+
return "Address is: {}".format(self.address)
64+
65+
66+
def available_menus(self, time):
67+
for menu in self.menus:
68+
if (time >= menu.start_time) and (time <= menu.end_time):
69+
return "Available Items are: {}".format(list(menu.items))
70+
71+
72+
# Franchaise Objects
73+
flagship_store = Franchise("1232 West End Road", (brunch, kids, dinner, early_bird))
74+
75+
new_installment = Franchise("12 East Mulberry Street", (brunch, kids, dinner, early_bird))
76+
77+
78+
# Testing Franchaise Instance
79+
print(new_installment.available_menus(17))
80+
81+
82+
83+
84+
85+
86+
87+
88+
# Creating Business Class
89+
90+
class Business:
91+
def __init__(self, name, franchises):
92+
self.name = name
93+
self.franchise = franchises
94+
95+
96+
# Business Instance
97+
basta_fazoolin = Business("Basta Fazoolin' with my Heart", [flagship_store, new_installment])
98+
99+
100+
# Another Business
101+
102+
# Menu Object
103+
arepa_menu = Menu("arepa menu", {
104+
'arepa pabellon': 7.00, 'pernil arepa': 8.50, 'guayanes arepa': 8.00, 'jamon arepa': 7.50
105+
}, 10, 20)
106+
107+
# Franchaise Object
108+
arepas_place = Franchise("189 Fitzgerald Avenue", arepa_menu)
109+
110+
# Business Object
111+
take_a_arepa = Business("Take a Arepa", [arepas_place])

0 commit comments

Comments
 (0)