-
Notifications
You must be signed in to change notification settings - Fork 1
/
dairyproduct.py
44 lines (40 loc) · 1.33 KB
/
dairyproduct.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
class DairyProduct:
def __init__(self, dairyId, dairyBrand, producttype, price, grade):
self.dairyId = dairyId
self.dairyBrand = dairyBrand
self.producttype = producttype
self.price = price
self.grade = grade
class ProductGrade:
def __init__(self, dairyList, weightDict):
self.dairyList = dairyList
self.weightDict = weightDict
def priceBasedOnBrandAndType(self, brand, type):
for i in range(len(self.dairyList)):
object = dairyList[i]
if object.dairyBrand == brand and object.producttype == type:
updateedPrice = object.price + \
object.price* self.weightDict[object.grade]/100
result = object.dairyBrand + " : "+updateedPrice
return result
else:
return None
NoOfProds = int(input())
dairylist = []
for i in range(NoOfProds):
did = int(input())
brand = input()
ptype = input()
price = int(input())
grade = input()
dairylist.append(DairyProduct(did, brand, ptype, price, grade))
wDict = {}
NoOfGrade = int(input)
for i in range(NoOfGrade):
grade = input()
value = input()
wDict[grade] = value
brand = input()
btype = input()
ProductGrade(dairylist, wDict)
print(ProductGrade.priceBasedOnBrandAndType(brand, btype))