Class FlightBookingSystem

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

public class FlightBookingSystem extends Object
Represents the flight booking system.
  • Constructor Details

    • FlightBookingSystem

      public FlightBookingSystem()
  • Method Details

    • getSystemDate

      public LocalDate getSystemDate()
      Retrieves the current date of the system.
      Returns:
      The current date of the system
    • addBooking

      public void addBooking(Booking booking)
      Adds a booking to the system.
      Parameters:
      booking - The booking to be added to the system
    • getFutureFlights

      public List<Flight> getFutureFlights(LocalDate systemDate)
      Retrieves a list of all future flights in the system that have not departed.
      Parameters:
      systemDate - The current date of the system
      Returns:
      A list of all future flights in the system that have not departed
    • getCustomer

      public List<Customer> getCustomer()
      Retrieves a list of all customers in the system.
      Returns:
      A list of all customers in the system
    • getFlightByID

      public Flight getFlightByID(int delId) throws FlightBookingSystemException
      Retrieves a flight by its ID.
      Parameters:
      delId - The ID of the flight to retrieve
      Returns:
      The flight with the specified ID
      Throws:
      FlightBookingSystemException - If no flight exists with the given ID
    • getCustomerByID

      public Customer getCustomerByID(int id) throws FlightBookingSystemException
      Retrieves a customer by their ID.
      Parameters:
      id - The ID of the customer to retrieve
      Returns:
      The customer with the specified ID
      Throws:
      FlightBookingSystemException - If no customer exists with the given ID
    • addFlight

      public void addFlight(Flight flight) throws FlightBookingSystemException
      Adds a flight to the system.
      Parameters:
      flight - The flight to be added to the system
      Throws:
      FlightBookingSystemException - If a flight with the same ID or same number and departure date already exists in the system
    • addCustomer

      public void addCustomer(Customer customer) throws FlightBookingSystemException
      Adds a customer to the system.
      Parameters:
      customer - The customer to be added to the system
      Throws:
      FlightBookingSystemException - If a customer with the same ID already exists in the system
    • getCustomers

      public Customer[] getCustomers()
      Retrieves an array of all customers in the system.
      Returns:
      An array of all customers in the system
    • issueBooking

      public void issueBooking(Customer customer, Flight flight, LocalDate bookingDate) throws FlightBookingSystemException
      Issues a booking for a customer on a flight with the specified booking date.
      Parameters:
      customer - The customer for whom the booking is issued
      flight - The flight for which the booking is issued
      bookingDate - The date on which the booking is made
      Throws:
      FlightBookingSystemException - If the customer or flight does not exist in the system, or if the flight is at full capacity
    • getBookings

      public Booking[] getBookings()
      Retrieves an array of all bookings in the system.
      Returns:
      An array of all bookings in the system
    • cancelBooking

      public void cancelBooking(int customerId, int flightId) throws FlightBookingSystemException
      Cancels a booking for a given customer and flight.
      Parameters:
      customerId - The ID of the customer
      flightId - The ID of the flight
      Throws:
      FlightBookingSystemException - If the customer or flight does not exist in the system
    • removeFlight

      public void removeFlight(Flight flightToDelete)
      Removes a flight from the system.
      Parameters:
      flightToDelete - The flight to be removed from the system
    • getBookingByID

      public Booking getBookingByID(int bookingID) throws FlightBookingSystemException
      Retrieves a booking by its ID.
      Parameters:
      bookingID - The ID of the booking to retrieve
      Returns:
      The booking with the specified ID
      Throws:
      FlightBookingSystemException - If no booking exists with the given ID
    • getCustomerByName

      public Customer getCustomerByName(String customerName) throws FlightBookingSystemException
      Retrieves a customer by their name.
      Parameters:
      customerName - The name of the customer to retrieve
      Returns:
      The customer with the specified name
      Throws:
      FlightBookingSystemException - If no customer exists with the given name, or if multiple customers with the same name exist and none is selected
    • getFlights

      public List<Flight> getFlights()
      Retrieves a list of all future flights in the system.
      Returns:
      A list of all future flights in the system
    • addFeedback

      public void addFeedback(int bookingID, int customerID, String message)
      Adds feedback for a specific booking.
      Parameters:
      bookingID - The ID of the booking for which feedback is provided
      customerID - The ID of the customer providing feedback
      message - The feedback message provided by the customer
    • getFeedbacks

      public List<Feedback> getFeedbacks()
      Retrieves all feedback provided by customers.
      Returns:
      A list of all feedback provided by customers
    • addFeedback

      public void addFeedback(Feedback feedback)