Trains - The Veins of India

Moving on, let us find out how far our railway goes! Yes, Here come the scope and overview of the project. 

This is the project which supports a social cause. People become tiresome by the offline work. This is the object-oriented approach for Railway Reservation System Design.

Trains in India

Majorly the system consists of two broad levels and three including minor level inheritance. The base class, moderator access class, and passenger access class. As we know in reality there are various levels of administration. Managers are having different levels of authority which reflects into privacy and access to the system. Here is the crude implementation of the system. 

Base Class


Moderator Class


The ‘Base class’ is the first and topmost level of inheritance which stores the data of registree. Security care is taken while inheriting the data. ‘Moderator class’ indicated roles of moderator in the administration who have access to the details of trains and their modifications. Whereas the ‘Passenger class’ represents a passenger, the most important part of the community who makes the system wholesome, is another class in the second level of inheritance. ‘Trains’ is the other class which stores all the details of the trains. Let us add some coal, gear up the engine and push though the boundless roads! Let us look deeper.

Trains Class

Passenger Class












The base class consists of all personal data and should be kept private for the rest people. It includes details of passengers and their reservation priorities. As listed, the name signifies the name of the registree. Age, gender is also considered to implement reservation categories of registree. The number of seats shows how much seats users want to book. Train number points towards the train for which registration is to be done. Lastly, Charges calculate how much amount the seat takes for the travel. Priority is set for the reservation people like women and aged people. 

Then comes the Passengers. It includes all the functions which are dedicated to operations for passengers. ‘Reservation’ function helps registree to book the train. They have to provide the details as mentioned above. ‘registration_cancel’ function cancels the already booked ticket. ‘check_vacancy’ function checks the vacancy and alerts the user if out if seats. ‘display_passenger_list’ function helps to display the details of passengers whereas, ‘view_train_Details’ function displays current details of all trains. ‘printticket’ prints the personalized ticket of a passenger. 

Let us move to the next boogie! Moderator class it is! Alert higher authorities here. This class includes details of trains. An object of this class can delete or add trains. Also, the timings can be changed because of delay in arrival or departure. The Moderator class has access to all data of passengers as well as its own. However, it is not true the other way. A friend class concept is used here. 

And, the guard boogie comes with a green flag! Here are the last of classes -  ‘Trains’. This class includes details of trains- train number which is the private key, train name, starting place and ending place, charges, and timing of arrival. Everyone has access to trains but edit access is only for moderator. 



So that is all! The Train has departed with full of passengers. Let’s explore the binding elements of these boogies now. Inheritance and friend functions are important concepts used throughout the code. Let us look into it one by one!

Inheritance

It is one of the building blocks of OOP in C++. Inheritance is a process in which one object acquires all the properties and behaviors of its parent object automatically. In such away, you can reuse, extend or modify the attributes and behaviors which are defined in other class. Now you can reuse the members of your parent class. So, there is no need to define the member again. So less code is required in the class.

Here are some types of Inheritance.

Types of Inheritance

Stay tuned for more details of Inheritance in the following blog! Till then estimate which Inheritance we are using in this design. Be on rails! Don't miss the flags too!

Hoo- hoo! Here is the next tier of this system, the ‘Friend’ function.

FRIEND Function


If a function is defined as a friend function in C++, then the protected and private data of a class can be accessed using the function. By using the keyword friend compiler knows the given function is a friend function. For accessing the data, the declaration of a Friend function should be done inside the body of a class starting with the keyword friend.

Characteristics of a Friend function:

  • The function is not in the scope of the class to which it has been declared as a friend.
  • It cannot be called using the object as it is not in the scope of that class.
  • It can be invoked like a normal function without using the object.
  • It cannot access the member names directly and has to use an object name and dot membership operator with the member name.
  • It can be declared either in the private or the public part.


And, here comes the station. Stay tuned for the next blog to get more detailed notes insights of this ‘Grey Hound Express’!


- Sampada Petkar (K 62)

Comments

  1. Well written! Informative

    ReplyDelete
  2. Interesting approach to solve the problem!

    ReplyDelete
  3. Helpful information! Great work ๐Ÿ‘

    ReplyDelete
  4. Nice use of OOP concepts. I liked that.

    ReplyDelete
  5. Very much informative.. Great work๐Ÿ‘

    ReplyDelete
  6. Very interesting information....well done๐Ÿ‘✌

    ReplyDelete
  7. Everything explained in an informative way.. Precisely presented..๐Ÿ‘

    ReplyDelete
    Replies
    1. Thank you! Good you like it, give read to following blogs!

      Delete
  8. Excellent use of OOPs concepts in day to day applications.....Very well written article!!

    ReplyDelete
    Replies
    1. Thanks! It's good you found it helpful. Give read to following blogs as well!

      Delete

Post a Comment

Popular posts from this blog

Do you have a ticket?

It's moderator's Office

Dynamic Memory Allocation in C++