Click of a Button

The great thing about the internet is that it has brought the world closer to an unimaginable extent and everything is available at the tip of your fingertips. The internet has made our life so easy that people can literally make their living off of the internet. On the same basis making your travel arrangements has gotten easier. Standing in line for booking your tickets is a thing of the past.


So, the project that our group has been working on is making a railway reservation system and in this blog, we will be discussing the booking of the ticket and the canceling of the ticket part.

Booking the ticket

The most important concept that we have applied in this part is the concept of inheritance.

Just to give you a small recap, inheritance is the process in which one class inherits the data members of another class and can use the members without redeclaring them and creating a ruckus. 

When you run the program, the window that first pops up looks like this 


Now to book the ticket the choice you have to pick is the first option. So, to book a ticket you have to press 1. So, basically, we have used switch case to call the function when you press the desired option. So, when you press ‘1’ the interface of the booking part comes up, where it first asks your name, age, and gender. After entering the prerequisites, the program displays the number of trains with their unique number and name and the destination it will take you.

Further, the program asks you to pick a train by their train number. It then asks you to enter the number of seats. Once you enter that, that’s it. The REGISTRATION IS SUCCESSFUL. 

The whole process pretty much looks like this:


Canceling a ticket

Just like for booking a ticket has its own different function, the cancellation of a ticket also has its own function. To cancel the ticket the user has to press ‘2’ and using switch case the code is directly drawn to the function that cancels the reservation. When his occurs, the program asks the same questions for the prerequisites that it did earlier. So, this is done for tallying the information done while booking the ticket so we don’t delete someone else’s ticket. 

Basically, there are two ways to delete a ticket from the sequence. First, is the quintessential static programming method where everything is stored in the form of an array and the element you want to remove is simply removed from the array. But in our project, we have sought a dynamic approach and decided to use a linked list instead. So, in short, what a linked list is basically when elements are connected in an array and one element stores two things, the data of the element and the address of the following element it points to. 

So, when you want to remove an element from a linked list what you can do is point the previous element of the element that you want to remove to the element that is in front of the element you want to remove. This may sound confusing but it will be easier to understand from a visual representation.


This is how a node is deleted in a linked list.

Once the ticket is deleted, you get REGISTRATION CANCELED message. The whole process looks like this:



- Sagar Potnis (K63)

References -




Comments

Post a Comment

Popular posts from this blog

Do you have a ticket?

It's moderator's Office

Dynamic Memory Allocation in C++