You are on page 1of 1

TrainTicket.

py
pass
class Train:
def __init__(self,name,fare,seats):
self.name=name
self.fare=fare
self.seats=seats

def getsatus(self):
print(".........")
print(f"the name of train is{self.name}")
print(f"the seats available in the train are{self.seats}")
print("..........")
def fareInfo(self):
print(f"the price of the tickets is : KShs {self.fare}")

def bookTicket(self):
if(self.seats>0):
print(f"your ticket has been booked!!!!!!!! your seat number is :
{self.seats}")
self.seats =self.seats -1
else:
print("sorry this train is full!!!")
def cancelTicket(self,seatNo):
pass
intercity = Train("intercity Express : 14520", 90,2)
intercity.getStatus()
intercity.bookTicket()
intercity.bookTicket()
intercity.bookTicket()
intercity.getStatus()

You might also like