Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Project Title: Airline Reservation System

Description:
Welcome to the Airline Reservation System project! This project aims to create a Java program
to simulate an airline reservation system, allowing users to search for flights, book seats,
manage reservations, and handle baggage. The project involves several classes, including
Flight, Reservation, AirlineReservationSystem, and AirlineReservationSystemApp.

Detailed Information about Classes:

Flight Class:
​ Properties:
● String flightNumber: Unique identifier for the flight.
● String origin: Departure location of the flight.
● String destination: Arrival location of the flight.
● int capacity: Maximum number of seats available on the flight.
● int bookedSeats: Number of seats already booked on the flight.
● String status: Current status of the flight (e.g., On Time, Delayed, Canceled).
● double baggageFee: Fee charged for checked baggage.
​ Constructor:
● Initializes all properties of the flight.
​ Methods:
● Getters and Setters
● bookSeat(): Books a seat on the flight. If there are available seats, increments
bookedSeats and returns true; otherwise, returns false.
● cancelSeat(): if bookedSeats number is greater than 0 then bookedSeats should
be decreased by 1
● setStatus(String status): Updates the status of the flight to the given in
parameters.
● setBaggageFee(double baggageFee): Sets the baggage fee for the flight.
● toString(): Formats flight information for display.

Reservation Class:
​ Properties:
● String passengerName: Name of the passenger.
● String flightNumber: Flight number booked for the reservation.
● int baggageCount: Number of checked bags for the reservation.
​ Constructor:
● Initializes all properties of the Reservation.
​ Methods:
● Create Getter methods.
AirlineReservationSystem Class:
​ Properties:
● HashMap<String, Flight> flights: Collection of flights indexed by their flight
numbers. A map of flightNumbers and flight objects.
● ArrayList<Reservation> reservations: List of reservations.
● double baggageFeePerBag: Default baggage fee per bag.
​ Methods:
● addFlight(Flight flight): Adds a flight to the flights hashMap.
​ flightNumber added as a key, flight object added as a value
● bookFlight(String flightNumber, String passengerName, int baggageCount):
1. Check from the HashMap if the flight with the given flightNumber in parameters
has availableSeats.
2. If there are available seats then create an object of Reservation class and add
it to the ArrayList reservations print a message that the “flight was booked for the
passenger and a baggage fee”.
3. If there are no available seats, print that the “flight is fully booked”.
4. If flight with the given flightTicket in parameters was not found print “flight was
not found”.
● cancelReservation(String passengerName): it should remove all reservations
made by the given passenger
1. Iterate over the reservations
2. if one reservation is registered for the given passengerName
3. Then pull out from map a flight with the flightTicket from the found reservation
and call cancelSeat() method
4. Then remove the reservation
Cancels a reservation, updates flight availability.
● listFlights(): Displays a list of available flights.
● listReservations(): Displays a list of reservations.
● updateFlightStatus(String flightNumber, String status):
1. If the flights hashMap contains the given flightNumber key then pull out the
object and set a new status
searchFlights(String origin, String destination):
1. If the map contains a flight with the given origin and destination then print
details about the flight.

AirlineReservationSystemApp Class:
​ Main Method:
● Create a scanner
● Creates an instance of AirlineReservationSystem airlineReservationSystem.

● Create the following flights and add them to the airlineReservationSystem:


● Program should have the following options:
1. List flights
2. Search flights
3. Book a flight
4. Cancel Reservation
5. List Reservations
6. Update Flight Status
7. Exit
Choose an option:
● Make your program interactive

Here are the expected scenarios:


Expected output:
1. List Flights
2. Search Flights
3. Book a Flight
4. Cancel Reservation
5. List Reservations
6. Update Flight Status
7. Exit
Choose an option: 1
List of Flights:
Flight Number: GHI789
Origin: Chicago
Destination: Dallas
Capacity: 120
Booked Seats: 0
Status: On Time
Baggage Fee: $20.0
----------------------
Flight Number: DEF456
Origin: Los Angeles
Destination: Chicago
Capacity: 150
Booked Seats: 0
Status: On Time
Baggage Fee: $30.0
----------------------
Flight Number: JKL012
Origin: Dallas
Destination: Houston
Capacity: 200
Booked Seats: 0
Status: On Time
Baggage Fee: $15.0
----------------------
Choose an option: 2
Enter origin: Chicago
Enter destination: Dallas
Flights from Chicago to Dallas:
Flight Number: GHI789
Origin: Chicago
Destination: Dallas
Capacity: 120
Booked Seats: 0
Status: On Time
Baggage Fee: $20.0
----------------------
Choose an option: 2
Enter origin: Dallas
Enter destination: Chicago
Flights from Dallas to Chicago:
No flights found for the specified route.
Choose an option: 3
Enter flight number: KKKK12
Enter passenger name: Mike
Enter number of checked bags: 1
Flight KKKK12 not found.
Choose an option: 3
Enter flight number: DEF456
Enter passenger name: Mike
Enter number of checked bags: 1
Flight DEF456 booked for Mike
Baggage fee: 25.0
Choose an option: 5
List of Reservations:
Passenger: Mike, Flights: DEF456, Baggage Count: 1
Choose an option:
Choose an option: 4
Enter passenger name: Mike
Reservation canceled for Mike

Choose an option: 6
Enter flight number: DEF456
Enter new status (On Time, Delayed, Canceled): Canceled
Flight status updated for DEF456 to Canceled
Choose an option: 3
Enter flight number: DEF456
Enter passenger name: Steve
Enter number of checked bags: 1
Sorry, the flight DEF456 is fully booked.
Choose an option: 6
Enter flight number: GHI789
Enter new status (On Time, Delayed, Canceled): Delayed
Flight status updated for GHI789 to Delayed
Choose an option: 3
Enter flight number: GHI789
Enter passenger name: Sara
Enter number of checked bags: 1
Flight GHI789 booked for Sara
Baggage fee: 25.0
Choose an option: 1
List of Flights:
Flight Number: GHI789
Origin: Chicago
Destination: Dallas
Capacity: 120
Booked Seats: 1
Status: Delayed
Baggage Fee: $20.0
----------------------
Flight Number: DEF456
Origin: Los Angeles
Destination: Chicago
Capacity: 150
Booked Seats: 0
Status: Canceled
Baggage Fee: $30.0
----------------------
Flight Number: JKL012
Origin: Dallas
Destination: Houston
Capacity: 200
Booked Seats: 0
Status: On Time
Baggage Fee: $15.0
----------------------
Choose an option: 7
Exiting

You might also like