-
Notifications
You must be signed in to change notification settings - Fork 0
/
product.py
executable file
·36 lines (21 loc) · 904 Bytes
/
product.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
import copy
class Product:
stock_msg_threshold = 10 # changes in stock below this value are signalled
def __init__(self, productDict):
self.dict = productDict.copy()
def __str__(self):
return "\n".join([key + ": " + str(val)
for key, val in sorted(self.dict.items())])
def update_string(self, old_dict):
"""
"""
def distinguish(key):
if(key in old_dict):
return str(self.dict[key]) +\
" (previously " + str(old_dict[key]) + ")"
else:
return str(self.dict[key])
return "\n".join(sorted([key + ": " + distinguish(key)
for key in self.dict.keys()])) + "\n"
def productType(self):
return "abstractProduct"