Class VIPSeatAllocation
java.lang.Object
bcu.cmp5332.bookingsystem.commands.VIPSeatAllocation
- All Implemented Interfaces:
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
ConstructorDescriptionVIPSeatAllocation
(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 TypeMethodDescriptionvoid
execute
(FlightBookingSystem flightBookingSystem) Executes the VIPSeatAllocation command within the provided FlightBookingSystem instance.
-
Constructor Details
-
VIPSeatAllocation
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 bookingflightId
- The ID of the flight to be bookedbookingDate
- The date on which the booking is madebookingid
- 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 interfaceCommand
- 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 processIOException
- If there is an error storing data using FlightBookingSystemData
-