A comprehensive console-based simulation of an Airline Reservation System (ARS). This application manages the complex relationships between Flights, Passengers, and Reservations without relying on a SQL database.
It demonstrates advanced Object-Oriented principles, including manual Dependency Injection, custom Comparators for scheduling, and robust string parsing for data persistence.
- Management: create and modify flight schedules with validation for unique Flight IDs (
Fxxxxformat). - Sorting Algorithm: Implements
Collections.sortwith a customComparatorto organize flights dynamically by departure time.
- Booking Logic: A multi-step process that links specific Passengers to Flights, generating a unique Reservation ID.
- Seat Allocation: Handles "Check-In" logic to assign gates and seats to passengers.
- Capacity Checks: Automatically validates available seats (
AvailSeat) before confirming a reservation.
- State Preservation: The system creates and reads from structured text files (
ReservationID.txt,FlightDetails.txt) to maintain state between sessions. - Complex Parsing: Utilizes
BufferedReaderand regex to reconstruct complex Object graphs (Reservation -> Flight -> List) from raw text.
To ensure data consistency between different modules, the system uses constructor injection to share the FlightList instance with the ReservationList.
// From ReservationList.java
public ReservationList(FlightList flightList) {
this();
this.flightList = flightList; // Logic injection for data consistency
}Unlike simple list-based apps, this project models real-world constraints where objects encapsulate other objects:
public class Reservation {
private int reservationId;
private Flight flight; // Object composition
ArrayList<Passenger> passenger; // One-to-Many relationship
// ...
}- Clone the repository:
git clone https://github.com/TonyTheSlacker/FlightReservation.git
- Compile the source:
javac Main.java
- Run the application:
java Main
Note: The application expects data files (FlightDetails.txt, etc.) to exist. If they are missing, the system will start with an empty database and generate them upon saving.