In this post, I am going to show you how you can be able to create a command-line Railway Reservation System Application using C++.

In this project, we have 7 different files 4 of which are the headers we will share between the application, 1 user application which will be used to reserve train from the available trains, 1 admin application the file will be used to monitor and capture all users activity and take action the last one is used to simulate the payment system.

Admin.cpp - Used to monitor Users activity
User.cpp - Main user appliction used to reserve train
Payoneer.cpp - Payment Simulation
LoginInformation.h - A Struct with the user information
requiredFees.h - Used to make payments
reservationDetail.h - A class to store the user reservation detail
trainInformation.h - Class reponsible for all the available and included trains detail

Let me explain every file. In the first file, we have the User.cpp which is responsible for handling all user-related information and payment information.

In this file, we have 15 functions.

userAccount(char *, int):- What this function does is it takes a userSSN object as a pointer and the userPassword if the passed parameters are correct shows the user menu(Navigation keys) for other functionalities.

registerNewUser():- This function is used to register user, what is does is it takes the userSSN and check if the user exists and if the user does exist it shows an error if not it then ask for a new password and adds the user to userFileLogin binary file.

userViewTrainDetail() :- This function show if there is any available train for reservation.

redirectReserveTrain() :- Redirects user after successful reservation.

reserveTrain():- This function takes the userSSN and PIN and checks if the user paid the required fee before reservation and if the user has paid the fee it check if the payment is made before 3 hours and if not it tells the user to wait 3 hours or less if it passes the user will then be registered to passengersDetail file. After the user registered to passengerDetail it then deletes the payment fee.

deleteFeeAfterReserve():- This function deletes the reservation fee after we have successfully reserved our seat.

cancelReservation():- What this function does is if we want to cancel the reservation it checks the reservation fee for the reservation and then reverses the payment fee to the user in payRequiredFee file and deletes the reservation information.

updateAfterCancel():- This function updates the paid fee in the above method.

updateReservation():- This function updates the user reservation detail if there are any changes the user wants to make.

checkFee():- This function takes the Train number, the number of seats, and the class number(First class, Second class) to reserve and then show the user the amount of money he has to pay in order to reserve the required seats.

messageBox():- This function shows the user reservation details history.

cancelPayment():- As the name suggests it takes the payment id and cancels that payment.

cancelAllPayment():- This function cancels all the payments made by the user.

cancelSinglePayment(): This function cancels a specific payment.

wallet():- This function show the user wallet or the amount of money the user have.

int flag, PIN = 0;
char s[2] = "S", f[2] = "F";

void userAccount(char*,int);                  
void registerNewUser();             
void userViewTrainDetail();      
void redirectReserveTrain(char*);              
void reserveTrain(char*,int);            
void deleteFeeAfterReserve(char*,int);     //Delete Paid Fee After Reservation
void cancelReservation(char*);             //Cancel Reservation
void updateAfterCancel();                  //Update Paid Fee After Cancellation
void updateReservation(int, char*);
void checkFee(char*);
void messageBox(char*);
void cancelPayment(char*);
void cancellAllPayment(char*);
void cancelSinglePayment(char*,int);
void wallet(char*);