Class Flight

java.lang.Object
bcu.cmp5332.bookingsystem.model.Flight

public class Flight extends Object
Represents a flight in the flight booking system.
  • Constructor Details

    • Flight

      public Flight(int id, String flightNumber, String origin, String destination, LocalDate departureDate, int capacity, double price, boolean isDeleted)
      Constructs a new Flight object with the specified attributes.
      Parameters:
      id - The unique identifier of the flight
      flightNumber - The flight number
      origin - The origin of the flight
      destination - The destination of the flight
      departureDate - The departure date of the flight
      capacity - The number of seats available on the flight
      price - The price per seat of the flight
      isDeleted - Indicates whether the flight is deleted from the system
  • Method Details

    • getId

      public int getId()
      Retrieves the unique identifier of the flight.
      Returns:
      The unique identifier of the flight
    • setId

      public void setId(int id)
      Sets the unique identifier of the flight.
      Parameters:
      id - The new unique identifier to be set for the flight
    • addPassenger

      public void addPassenger(Customer passenger) throws FlightBookingSystemException
      Adds a passenger to the flight.
      Parameters:
      passenger - The passenger to be added to the flight
      Throws:
      FlightBookingSystemException - If the flight is at full capacity
    • removePassenger

      public boolean removePassenger(Customer customer)
      Removes a passenger from the flight.
      Parameters:
      customer - The customer to be removed from the flight
      Returns:
      True if the passenger is removed successfully, false otherwise
    • deleteFlight

      public void deleteFlight()
      Marks the flight as deleted from the system.
    • getDeleteStatusFlight

      public boolean getDeleteStatusFlight()
      Checks if the flight is deleted from the system.
      Returns:
      True if the flight is deleted, false otherwise
    • getPassengerDetails

      public String getPassengerDetails()
      Retrieves details of passengers booked on the flight (name and phone number).
      Returns:
      Details of passengers booked on the flight
    • getFlightNumber

      public String getFlightNumber()
      Retrieves the flight number.
      Returns:
      The flight number
    • setFlightNumber

      public void setFlightNumber(String newFlightNumber)
      Sets the flight number.
      Parameters:
      newFlightNumber - The new flight number to be set
    • getOrigin

      public String getOrigin()
      Retrieves the origin of the flight.
      Returns:
      The origin of the flight
    • setOrigin

      public void setOrigin(String origin)
      Sets the origin of the flight.
      Parameters:
      origin - The new origin to be set for the flight
    • getDestination

      public String getDestination()
      Retrieves the destination of the flight.
      Returns:
      The destination of the flight
    • setDestination

      public void setDestination(String destination)
      Sets the destination of the flight.
      Parameters:
      destination - The new destination to be set for the flight
    • getDepartureDate

      public LocalDate getDepartureDate()
      Retrieves the departure date of the flight.
      Returns:
      The departure date of the flight
    • setDepartureDate

      public void setDepartureDate(LocalDate departureDate)
      Sets the departure date of the flight.
      Parameters:
      departureDate - The new departure date to be set for the flight
    • getPassengers

      public List<Customer> getPassengers()
      Retrieves a copy of the list of passengers booked on the flight.
      Returns:
      A copy of the list of passengers booked on the flight
    • getPassengerCount

      public int getPassengerCount()
      Retrieves the number of passengers booked on the flight.
      Returns:
      The number of passengers booked on the flight
    • getDetailsShort

      public String getDetailsShort()
      Retrieves a short string representation of the flight's details.
      Returns:
      A short string representation of the flight's details
    • getDetailsLong

      public String getDetailsLong()
      Retrieves a detailed string representation of the flight's details and passengers.
      Returns:
      A detailed string representation of the flight's details and passengers
    • getCapacity

      public int getCapacity()
      Retrieves the capacity of the flight (number of seats).
      Returns:
      The capacity of the flight
    • setCapacity

      public void setCapacity(int capacity)
      Sets the capacity of the flight (number of seats).
      Parameters:
      capacity - The new capacity to be set for the flight
    • getPrice

      public double getPrice()
      Retrieves the price per seat of the flight.
      Returns:
      The price per seat of the flight
    • setPrice

      public void setPrice(double price)
      Sets the price per seat of the flight.
      Parameters:
      price - The new price per seat to be set for the flight
    • calculatePrice

      public double calculatePrice(LocalDate systemDate)
      Calculates the price for the flight based on the number of days left for departure and the current capacity.
      Parameters:
      systemDate - The current date of the system
      Returns:
      The calculated price for the flight
    • hasDeparted

      public boolean hasDeparted(LocalDate systemDate)
      Checks whether the flight has already departed.
      Parameters:
      systemDate - The current date of the system
      Returns:
      True if the flight has departed, false otherwise