Train Ticket book and train status Solution using OOPS

 


class TrainDetails:
def __init__(self,name,fare,seats):
self.name=name
self.fare=fare
self.seats=seats

def getStatus(self):
print(f"The Name of the trian --{self.name} \nfare {self.fare} \nseats {self.seats}")
def BookTicket(self):
if(self.seats>0):

print(f"your ticket has been booked, Your seat no is {self.seats}")
self.seats=self.seats-1
else:
print("Sorry this Train is booked kindly check in tatkal")



train=TrainDetails("Garib rath Expres52",500,2)


train.getStatus()
train.BookTicket()
train.getStatus()
train.BookTicket()
train.getStatus()
train.BookTicket()

Comments

Popular posts from this blog

Healthy Programmmer PROJECT

Difference Between Procedural and Non-procedural Language

Dictionary Practice Question