-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrder.py
More file actions
25 lines (20 loc) · 693 Bytes
/
Order.py
File metadata and controls
25 lines (20 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class Order:
def __init__(self,location, purchase):
self.location = location
self.purchase = purchase
self.totalWeight = self.getTotalWeight()
def deliver(self, objectType, n):
if objectType in self.purchase:
if n<self.purchase[objectType]:
self.purchase[objectType] -=n
else:
del self.purchase[objectType]
return not bool(self.purchase)
def getTotalWeight(self):
total = 0
for i in self.purchase:
total += self.purchase[i]
return total
if __name__ == "__main__":
test = Order((3,2), {1:10, 2:20})
print test.totalWeight