python中的铁路订票程序

2024-06-06 13:36:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用python编写这个项目,我试图编写一个系统,允许用户预订、取消、打印火车票,并将他们所做的一切保存到一个单独的文件中,程序每次打开时读取该文件,关闭时用新信息重新保存。我陷入困境是因为我不知道下一步该做什么,我为预订定义了一个类,还定义了类内的一些方法。我最终将尝试编写一个GUI,用户只需点击按钮,输入他们想要预订的座位号,依此类推。这是我到目前为止所做的,我是一个新的程序员,所以请友好,我需要建议我下一步应该做什么,我是在正确的轨道上,还是我需要用另一种方式编码?我到目前为止所做的是:

class Reservation:
    def __init__ (self, seatCol, seatRow, department, destination, departure, price):
        self.__seatCol = seatCol
        self.__seatRow = seatRow 
        self.__departement = departement
        self.__destination = destination
        self.__departure = departure
        self.__price = price

    def selectDeparture(departure):
        #Asks the user to pick a departure

    def selectDestination(destination):
        #Asks the user to pick a destination

    def selectSeat(seatCol, seatRow, department): 
        #Asks the user to pick a seat and checks if it's already booked

    def ticketPrice (price):

    def printBookedTicket:

Tags: 文件theto用户self定义defdestination