class TicketMachine: def init(self): self.movies = { "1": "《喜羊羊与灰太狼》", "2": "《熊出没》", "3": "《哆啦A梦》" } self.showtimes = { "1": "8:00-11:00", "2": "13:00-15:00", "3": "18:00-20:00" } self.seats = [str(i) for i in range(1, 51)]

def get_movie(self):
    print("请选择电影:")
    for key, value in self.movies.items():
        print(key, value)
    movie = input()
    return self.movies.get(movie)

def get_showtime(self):
    print("请选择场次:")
    for key, value in self.showtimes.items():
        print(key, value)
    showtime = input()
    return self.showtimes.get(showtime)

def get_seat(self):
    print("请选择座位:")
    for seat in self.seats:
        print(seat, end=" ")
    print()
    seat = input()
    return seat

def print_ticket(self):
    movie = self.get_movie()
    showtime = self.get_showtime()
    seat = self.get_seat()
    print("电影:", movie)
    print("场次:", showtime)
    print("座位:", seat)
    print("购票成功!")

ticket_machine = TicketMachine() ticket_machine.print_ticket()

帮我创建一个Python文件要求如下。售票机类创建以下方法:选择的电影选择场次选择座位并打印结果。电影选择有《喜羊羊与灰太狼》《熊出没》《哆啦A梦》场次有800-11001300-15001800-2000。座位选择1到50号。写简单一点的python语言

原文地址: https://www.cveoy.top/t/topic/bUn5 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录