-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfood.py
81 lines (61 loc) · 2.01 KB
/
food.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Written by XJ
from inventory import *
from restaurant_system import *
from order import *
class Main():
def __init__(self, containers, contents, extra):
self._containers = containers # refer to buns/wraps
self._contents = contents # refer to patties
self._extra = extra # refers to extra choices, list object
def getprice(self):
price = 0 + self._containers.price * self._containers.quantity + self._contents.price * self._contents.quantity
for item in self._extra:
price = price + item.price * item.quantity
return price
@property
def containers(self):
return self._containers
@property
def contents(self):
return self._contents
@property
def extra(self):
return self._extra
def __str__(self):
return f'{self.containers.name} {self.contents.name} {self.ingredients.name} for ${self.price}'
class Main_Component(): # components of main, eg: containers contents and ingredients
def __init__(self, name, price, quantity):
self._name = name
self._price = price
self._quantity = quantity
@property
def name(self):
return self._name
@property
def price(self):
return self._price
@property
def quantity(self):
return self._quantity
class Other(): # sides and drinks
def __init__(self, name, price, quantity):
self._name = name
self._price = price
self._quantity = quantity
''' Important Notice:
quantity measures the basic unit
eg: 100mL juice -> quantity = 100
3 nuggets -> quantity = 3'''
def getprice(self):
return self._price * self._quantity
@property
def name(self):
return self._name
@property
def price(self):
return self._price
@property
def quantity(self):
return self._quantity
def __str__(self):
return f'{self.quantity} {self.name} for ${self.getprice(price, quantity)}'