-
Notifications
You must be signed in to change notification settings - Fork 14
/
28_March_Movie.py
60 lines (60 loc) · 1.43 KB
/
28_March_Movie.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
class Movie:
def __init__(self,id,name,price,cat):
self.id=id
self.name=name
self.price=price
self.cat=cat
def category(self):
if self.price>0 and self.price<150:
self.cat="General"
elif self.price>=150 and self.price<250:
self.cat="Silver"
elif self.price>=250 and self.price<350:
self.cat="Gold"
elif self.price>=350:
self.cat="Platinum"
class Ticket:
def __init__(self,cname,mname,vcount,total):
self.cname=cname
self.mname=mname
self.vcount=vcount
self.total=total
def getCount(mlist):
d={"General":0,"Silver":0,"Gold":0,"Platinum":0}
for i in mlist:
if i.cat in d:
d[i.cat]+=1
return d
def book(mlist,cname,mgiven,vcount):
flag=0
for i in mlist:
if i.name.lower()==mgiven.lower():
flag=1
t=i.price
if flag==0:
return None
else:
return Ticket(cname,mname,vcount,t*vcount)
if __name__=="__main__":
t=int(input())
mlist=[]
for i in range(t):
id=int(input())
name=input()
price=int(input())
ob=Movie(id,name,price,"Default")
ob.category()
mlist.append(ob)
v=getCount(mlist)
print("Category wise ticket count:")
for i in v:
if v[i]!=0:
print(i+':'+str(v[i]))
cname=input()
mname=input()
vcount=int(input())
b=book(mlist,cname,mname,vcount)
if b==None:
print('Movie not available')
else:
print(b.cname,b.total)