Class Booking

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

public class Booking extends Object
Represents a booking made by a customer for one or more flights. A booking can have an outbound flight and optionally a return flight.
  • Constructor Details

    • Booking

      public Booking(Customer customer, Flight outboundFlight)
      Constructs a new Booking object with only an outbound flight.
      Parameters:
      customer - The customer making the booking
      outboundFlight - The outbound flight to be booked
    • Booking

      public Booking(Customer customer, Flight outboundFlight, Flight returnFlight)
      Constructs a new Booking object with both outbound and return flights.
      Parameters:
      customer - The customer making the booking
      outboundFlight - The outbound flight to be booked
      returnFlight - The return flight to be booked
  • Method Details

    • getCustomer

      public Customer getCustomer()
      Retrieves the customer who made the booking.
      Returns:
      The customer who made the booking
    • getOutboundFlight

      public Flight getOutboundFlight()
      Retrieves the outbound flight of the booking.
      Returns:
      The outbound flight of the booking
    • getReturnFlight

      public Flight getReturnFlight()
      Retrieves the return flight of the booking.
      Returns:
      The return flight of the booking, or null if not available
    • getBookingDate

      public LocalDate getBookingDate()
      Retrieves the date when the booking was made.
      Returns:
      The date when the booking was made
    • isCancelled

      public boolean isCancelled()
      Checks if the booking is cancelled.
      Returns:
      True if the booking is cancelled, false otherwise
    • setCustomer

      public void setCustomer(Customer customer)
      Sets the customer associated with the booking.
      Parameters:
      customer - The customer to be associated with the booking
    • setOutboundFlight

      public void setOutboundFlight(Flight outboundFlight)
      Sets the outbound flight of the booking.
      Parameters:
      outboundFlight - The outbound flight to be set for the booking
    • setReturnFlight

      public void setReturnFlight(Flight returnFlight)
      Sets the return flight of the booking.
      Parameters:
      returnFlight - The return flight to be set for the booking
    • setBookingDate

      public void setBookingDate(LocalDate bookingDate)
      Sets the booking date of the booking.
      Parameters:
      bookingDate - The booking date to be set for the booking
    • cancelBooking

      public void cancelBooking()
      Cancels the booking by marking it as cancelled and applying a cancellation fee.
    • setPrice

      public void setPrice(double newPrice)
      Sets the price of the booking.
      Parameters:
      newPrice - The new price to be set for the booking
    • getId

      public int getId()
      Generates an ID for the booking based on the customer ID.
      Returns:
      The generated booking ID
    • toString

      public String toString()
      Provides a string representation of the booking.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the booking
    • setFlightNumber

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

      public Double getPrice()
      Retrieves the price of the booking.
      Returns:
      The price of the booking
    • applyPromocode

      public void applyPromocode(String promocode)