Package bcu.cmp5332.bookingsystem.model
Class Flight
java.lang.Object
bcu.cmp5332.bookingsystem.model.Flight
Represents a flight in the flight booking system.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPassenger
(Customer passenger) Adds a passenger to the flight.double
calculatePrice
(LocalDate systemDate) Calculates the price for the flight based on the number of days left for departure and the current capacity.void
Marks the flight as deleted from the system.int
Retrieves the capacity of the flight (number of seats).boolean
Checks if the flight is deleted from the system.Retrieves the departure date of the flight.Retrieves the destination of the flight.Retrieves a detailed string representation of the flight's details and passengers.Retrieves a short string representation of the flight's details.Retrieves the flight number.int
getId()
Retrieves the unique identifier of the flight.Retrieves the origin of the flight.int
Retrieves the number of passengers booked on the flight.Retrieves details of passengers booked on the flight (name and phone number).Retrieves a copy of the list of passengers booked on the flight.double
getPrice()
Retrieves the price per seat of the flight.boolean
hasDeparted
(LocalDate systemDate) Checks whether the flight has already departed.boolean
removePassenger
(Customer customer) Removes a passenger from the flight.void
setCapacity
(int capacity) Sets the capacity of the flight (number of seats).void
setDepartureDate
(LocalDate departureDate) Sets the departure date of the flight.void
setDestination
(String destination) Sets the destination of the flight.void
setFlightNumber
(String newFlightNumber) Sets the flight number.void
setId
(int id) Sets the unique identifier of the flight.void
Sets the origin of the flight.void
setPrice
(double price) Sets the price per seat of the flight.
-
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 flightflightNumber
- The flight numberorigin
- The origin of the flightdestination
- The destination of the flightdepartureDate
- The departure date of the flightcapacity
- The number of seats available on the flightprice
- The price per seat of the flightisDeleted
- 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
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
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
Retrieves details of passengers booked on the flight (name and phone number).- Returns:
- Details of passengers booked on the flight
-
getFlightNumber
Retrieves the flight number.- Returns:
- The flight number
-
setFlightNumber
Sets the flight number.- Parameters:
newFlightNumber
- The new flight number to be set
-
getOrigin
Retrieves the origin of the flight.- Returns:
- The origin of the flight
-
setOrigin
Sets the origin of the flight.- Parameters:
origin
- The new origin to be set for the flight
-
getDestination
Retrieves the destination of the flight.- Returns:
- The destination of the flight
-
setDestination
Sets the destination of the flight.- Parameters:
destination
- The new destination to be set for the flight
-
getDepartureDate
Retrieves the departure date of the flight.- Returns:
- The departure date of the flight
-
setDepartureDate
Sets the departure date of the flight.- Parameters:
departureDate
- The new departure date to be set for the flight
-
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
Retrieves a short string representation of the flight's details.- Returns:
- A short string representation of the flight's details
-
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
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
Checks whether the flight has already departed.- Parameters:
systemDate
- The current date of the system- Returns:
- True if the flight has departed, false otherwise
-