题目及要求:在电影院中观看电影是一项很受欢迎的休闲娱乐,现在,请模拟电影院自动售票机中自动选择电影场次的页面,例如,一部电影在当日的播放时间有很多,可以自动选择合适的场次。
【参考代码】
```
class Selecet:
def __init__(self):
self.moviesinfo = {'《白蛇:缘起》':{'time':['9:30','10:40','12:00','14:00','16:30'],'seat':['10-01','10-02','10-03','10-04']},'《流浪地球》':{'time':['8:30','9:40','12:50','15:00','18:50'],'seat':['09-01','09-02','08-03','06-04']},'《战狼2》':{'time':['8:30','9:40','12:50','15:00','18:50'],'seat':['09-01','09-02','08-03','06-04']}}
self.selemovie = ''
self.times = ''
self.zuowei1 = ''
self.SSS = 0
self.XXX = 0
def selecet_movie(self):
listmovie=[]
print('请选择正在上映的电影:',end='')
for i in self.moviesinfo:
listmovie.append(i)
for j in range(len(self.moviesinfo)):
print(' '+str(j+1)+'、'+listmovie[j],end='')
userselect = int(input(' '))
self.selemovie = listmovie[userselect-1]
print('已选择电影'+self.selemovie)
return self.selemovie
def changci(self):
print('请选择播放场次:(按场次对应数字输入)',end='')
self.times = self.moviesinfo[self.selemovie]['time']
for i in range(len(self.times)):
print(' '+str(i+1)+'、'+self.times[i],end='')
self.SSS = int(input(' '))
print('选择场次是:'+self.times[self.SSS-1])
def zuowei(self):
print('请选择座位:(按场次对应数字输入)',end='')
self.zuowei1 = self.moviesinfo[self.selemovie]['seat']
for i in range(len(self.zuowei1)):
print(' '+str(i+1)+'、'+self.zuowei1[i],end='')
self.XXX = int(input(' '))
print('选择座位是:'+self.zuowei1[self.XXX-1])
def allinfo(self):
print('正在出票...\n')
print('电影:'+self.selemovie)
print('播出时间:'+self.times[self.SSS-1])
print('选择座位是:'+self.zuowei1[self.XXX-1])
print('\n出票完成,请别忘记取票!')
def main(self):
self.selecet_movie()
self.changci()
self.zuowei()
self.allinfo()
seleceted = Selecet()
seleceted.main()
```