21BCM055 - TrainTicketReservation - CLI Python
21BCM055 - TrainTicketReservation - CLI Python
21BCM055 - TrainTicketReservation - CLI Python
class train_reserve:
def get_info():
venues=['coimbatore','chennai','bangalore','calcutta']
venues.remove(inf['starting_point'])
inf['destination']=input("destination {} :".format(venues))
def train_booking():
path=[]
journey=inf['starting_point']+'-'+inf['destination']
print("Available trains")
for t in trains:
if str.__contains__(t,journey):
path.append(trains[t])
path.append(trains[t][0][0])
inf['price']=accessing_dict[0]
total_seats=accessing_dict[1]
seat.sort()
verify=str(inf['train'])+"-"+str(inf['coach'])
if str.__contains__(str(reserved),verify):
if str.__contains__(str(seating),str(seat)):
print("already reserved")
print("__________________",end="\n")
obj.train_booking()
else:
inf['seats']=seat
else:
inf['seats']=seat
inf['amount']=len(inf['seats'])*inf['price']
def download_ticket():
print("\n_____________________________________________")
print("\n****** Journey details ******")
print("\n_____________________________________________")
joint=str(inf['train'])+"-"+str(inf['coach'])
seating.append(inf['seats'])
reserved.append(joint)
def payment():
print("Amount : {}".format(inf['amount']))
try:
cvv=input("CVV no : ")
time_over = inputimeout(timeout=40)
if submit=="CANCEL":
elif submit=="PAY":
obj.download_ticket()
else:
print("Not Valid.")
obj.payment()
except Exception:
print(time_over)
obj.payment()
reserved=[]
inf={}
seating=[]
while(True):
obj=train_reserve
obj.get_info()
obj.train_booking()
obj.payment()
switch=input("\n\n stay/leave:")
if switch=="leave":
break
OUTPUT:
Gender (M/F) : M
Available trains
enter coach 1 A / 2 A / 3 A / SL :2 A
Amount : 10850
CVV no : 121
******passenger details******
Name : Parthiban A
destination : bangalore
_____________________________________________
_____________________________________________
stay/leave:stay
Gender (M/F) : M
Available trains
enter coach 1 A / 2 A / 3 A / SL :2 A
already reserved
__________________
Available trains
Train name : Duronto Express
enter coach 1 A / 2 A / 3 A / SL :2 A
Amount : 10850
CVV no : 121
******passenger details******
Name : LeoDas A
destination : bangalore
_____________________________________________
****** Journey details ******
Coach :2A
_____________________________________________
stay/leave:leave
[Program finished]