The Railway Management System is a Java-based application that provides a graphical user interface (GUI) for managing railway operations, including booking tickets, searching for trains, and viewing train schedules. The system is designed using Object-Oriented Programming (OOP) principles to ensure modularity, scalability, and maintainability.
- Login System: Login functionality to access the system.
- Train Search: Search for trains between two stations for a specified date.
- Booking System: Book tickets by providing passenger details, seat preferences, and payment information.
- Train Schedules: View detailed train schedules, including departure and arrival times.
The Railway Management System leverages several key Object-Oriented Programming concepts:
- Station: Represents a railway station with a name and a list of tracks connected to it.
- Track: Represents a track between two stations with a specified distance.
- Train: Represents a train with an ID, name, schedule, and delay information.
- Booking: Represents a booking with details like train, stations, date, passenger name, seat, and payment info.
Encapsulation is used to bundle the data (attributes) and methods (functions) that operate on the data within a single unit or class. This helps in protecting the internal state of an object from unintended modifications.
- Each class has private fields and public methods to access and modify those fields.
- Example: The
Station
class has private attributes and methods to manage tracks.
Inheritance allows one class to inherit the fields and methods of another class. Although this project does not have an explicit inheritance hierarchy, it could be extended to have more specialized types of trains or stations.
Polymorphism allows objects to be treated as instances of their parent class rather than their actual class. This can simplify the code and enhance flexibility.
Abstraction involves hiding the complex implementation details and showing only the necessary features of an object. The GUI components (like buttons, labels, and frames) interact with the backend logic without exposing the complex details.
-
Station:
- Attributes:
name
,tracks
- Methods: Constructor, methods to manage tracks
- Attributes:
-
Track:
- Attributes:
from
,to
,distance
- Methods: Constructor
- Attributes:
-
Train:
- Attributes:
id
,name
,schedule
,delay
- Methods: Constructor
- Attributes:
-
Booking:
- Attributes:
train
,from
,to
,date
,passengerName
,seat
,paymentInfo
- Methods: Constructor
- Attributes:
- Main: The main class initializes the data and creates the GUI windows.
setupData()
: Initializes stations, tracks, and trains.createWelcomePage()
: Creates the welcome screen.createLoginPage()
: Creates the login screen.createSearchPage()
: Creates the train search screen.createTrainListPage()
: Displays the list of available trains.createBookingPage()
: Creates the booking details screen.createThankYouPage()
: Displays the booking confirmation.
- Java Development Kit (JDK) installed on your machine.
- An IDE or text editor for Java development (e.g., IntelliJ IDEA, Eclipse, VS Code).
- Clone the repository to your local machine.
- Open the project in your preferred IDE.
- Compile and run the
Main
class. - Follow the GUI prompts to use the Railway Management System.