In this Python version 3.12 Project, We are Developing a Train Ticket Reservation Project using Class and Methods. This Project consist of the Passenger and Train details gathering and also Train Ticket Confirmation process.
#Code :
class train_ticket:
def train(self):
print("\nTRAIN RESERVATION")
self.source=input("Enter Your Location : ").capitalize()
self.des=input("Enter Your Destination : ").capitalize()
self.date=input("Enter the Date : dd/mm/yyyy\n")
self.cls=input("Select Class of Train : Sleeper/3AC/2AC : ").upper()
self.seat=int(input("Enter the Seat Number : "))
def passenger(self):
print("\nPASSENGER DETAILS ENTRY")
self.name=input("Enter Name : ").capitalize()
self.age=int(input("Enter Age : "))
self.gen=input("Enter Gender : ").capitalize()
self.aadhar=int(input("Enter Aadhar No : "))
print("\nPAYMENT PROCESS")
self.upi=input("Enter the UPI Id : ")
def confirmation(self):
print("\nPASSENGER DETAILS")
print("Kindly Check Your Details")
print(f"Name : {self.name}")
print(f"Age : {self.age}")
print(f"Gender : {self.gen}")
print(f"Aadhar No : {self.aadhar}")
print(f"Location : {self.source}")
print(f"Destination : {self.des}")
print(f"Date : {self.date}")
print(f"Class : {self.cls}")
print(f"Seat No : {self.seat}")
print(f"UPI Id : {self.upi}")
self.con=input("Do You want to confirm your ticket ? : Y/N : ").upper()
if self.con=='Y':
print("\n\tYOUR TICKET RESERVATION PROCESS SUCCESSFULLY COMPLETED")
else:
print("\n\tYOUR TICKET RESERVATION PROCESS IS UNSUCCESSFUL : PLEASE TRY AGAIN")
t=train_ticket()
print("\tWELCOME TO TRAIN TICKET RESERVATION PORTAL")
t.train()
t.passenger()
t.confirmation()