-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathProduct.py
41 lines (41 loc) · 880 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
37
38
39
40
41
class Product:
def __init__(self,id,name,ptype,price):
self.id=id
self.name=name
self.ptype=ptype
self.price=price
def discount(self,dis):
self.price-=(self.price*dis)/100
class Store:
def __init__(self,sname,plist):
self.sname=sname
self.plist=plist
def calc(self,dis,p):
b={}
flag=0
for i in self.plist:
if i.ptype.lower()==p.lower():
flag=1
i.discount(dis)
b[i.price]=i.name
if flag==1:
return b
else:
return None
t=int(input())
plist=[]
for i in range(t):
id=int(input())
name=input()
ptype=input()
price=int(input())
plist.append(Product(id,name,ptype,price))
ob=Store("abc",plist)
p=input()
d=int(input())
s=ob.calc(d,p)
if s==None:
print('Product not found')
else:
for i in sorted(s,reverse=True):
print(s[i],i)