Class VIPSeatAllocation

java.lang.Object
bcu.cmp5332.bookingsystem.commands.VIPSeatAllocation
All Implemented Interfaces:
Command

public class VIPSeatAllocation extends Object implements Command
The VIPSeatAllocation class represents a command to allocate a VIP seat to a specific customer on a specific flight, even if the flight is fully booked. If the flight is full, a regular booking is cancelled to make room for the VIP booking.

Example usage:


 int customerId = 1;
 int flightId = 101;
 LocalDate bookingDate = LocalDate.now();
 int bookingid = 123; // Replace with actual booking ID
 Command vipSeatAllocationCommand = new VIPSeatAllocation(customerId, flightId, bookingDate, bookingid);
 vipSeatAllocationCommand.execute(flightBookingSystem);
 
  • Field Summary

    Fields inherited from interface bcu.cmp5332.bookingsystem.commands.Command

    HELP_MESSAGE
  • Constructor Summary

    Constructors
    Constructor
    Description
    VIPSeatAllocation(int customerId, int flightId, LocalDate bookingDate, int bookingid)
    Constructs a VIPSeatAllocation command with the specified customer ID, flight ID, booking ID, and booking date.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    execute(FlightBookingSystem flightBookingSystem)
    Executes the VIPSeatAllocation command within the provided FlightBookingSystem instance.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • VIPSeatAllocation

      public VIPSeatAllocation(int customerId, int flightId, LocalDate bookingDate, int bookingid)
      Constructs a VIPSeatAllocation command with the specified customer ID, flight ID, booking ID, and booking date.
      Parameters:
      customerId - The ID of the customer making the VIP booking
      flightId - The ID of the flight to be booked
      bookingDate - The date on which the booking is made
      bookingid - The ID of the booking to be displaced if necessary
  • Method Details

    • execute

      public void execute(FlightBookingSystem flightBookingSystem) throws FlightBookingSystemException, IOException
      Executes the VIPSeatAllocation command within the provided FlightBookingSystem instance. Retrieves the customer, flight, and booking based on IDs, checks if the flight has capacity, and if not, cancels the specified regular booking to make room for the VIP booking. If successful, the updated system data is stored using FlightBookingSystemData.
      Specified by:
      execute in interface Command
      Parameters:
      flightBookingSystem - The FlightBookingSystem instance on which the VIP booking is to be added
      Throws:
      FlightBookingSystemException - If the customer, flight, or booking does not exist, or if there is an error during the process
      IOException - If there is an error storing data using FlightBookingSystemData