Flight Booking System:


The Flight Booking System is a simple Java application that simulates flight booking for passengers. It includes a set of classes to represent flights, passengers, tickets, and a manager to handle flight booking operations. In our model, we will have Flight objects (representing flights) and we have passengers (either a frequent flyer member or a non-member) who want to book a flight for a travel. If a seat is available on a given flight, then a ticket will be issued at a price depending on whether the ticket is for a member or a non-member.



The Flight class represents a flight and has the following instance variables:

  • flightNumber (int): Unique flight number.
  •  origin (String): Flight’s origin.
  •  destination (String): Flight’s destination.
  • departureTime (String): Departure time of the flight.
  • capacity (int): Maximum capacity of the flight.
  • numberOfSeatsLeft (int): Number of available seats.
  •  originalPrice (double): Original price of the flight.

The class provides a constructor to initialize these variables, getters and setters for instance variables, and a ‘bookASeat()’ method to book a seat on the flight if available.


‘Passenger’ is an abstract class that represents common attributes for passengers:

  • ‘name’ (String): Passenger’s name.
  • ‘age’ (int): Passenger’s age.


‘Member’ is a subclass of Passenger. It includes an additional attribute:

  • yearsOfMembership (int): Number of years as a member.

This class overrides the applyDiscount(double p) method to provide discounts based on the years of membership.


NonMember is a subclass of Passenger. It doesn’t have any additional attributes. It also overrides the applyDiscount(double p) method to provide discounts based on the passenger’s age.


The Ticket class represents a flight ticket with the following attributes:

  • passenger (Passenger): The passenger who booked the ticket.
  • flight (Flight): The flight for which the ticket is booked.
  • price (double): The price of the ticket.
  • number (int): A unique ticket number.


The Manager class manages flights and ticket bookings. It provides the following methods:

  • createFlights(): Populate the array of flights by taking user input.
  • displayAvailableFlights(origin, destination): Display available flights from origin to destination.
  • getFlight(flightNumber): Get the Flight object for a specified flight number.
  • bookSeat(flightNumber, passenger): Find and book a seat on the specified flight. Apply discounts based on passenger type (Member or NonMember) and issue a ticket.