Class CancelBooking
java.lang.Object
bcu.cmp5332.bookingsystem.commands.CancelBooking
- All Implemented Interfaces:
Command
The CancelBooking class represents a command to cancel a booking for a specific customer on a specific flight.
It implements the Command interface and requires execution within a FlightBookingSystem instance.
The booking cancellation is performed by invoking the cancelBooking method on the flightBookingSystem with the specified customer ID and flight ID. Upon cancellation, the system updates and stores the modified booking data using FlightBookingSystemData.
Example usage:
int customerId = 1;
int flightId = 101;
Command cancelBookingCommand = new CancelBooking(customerId, flightId);
cancelBookingCommand.execute(flightBookingSystem);
-
Field Summary
Fields inherited from interface bcu.cmp5332.bookingsystem.commands.Command
HELP_MESSAGE
-
Constructor Summary
ConstructorDescriptionCancelBooking
(int customerId, int flightId) Constructs a CancelBooking command with the specified customer ID and flight ID. -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(FlightBookingSystem flightBookingSystem) Executes the CancelBooking command within the provided FlightBookingSystem instance.
-
Constructor Details
-
CancelBooking
public CancelBooking(int customerId, int flightId) Constructs a CancelBooking command with the specified customer ID and flight ID.- Parameters:
customerId
- The ID of the customer whose booking is to be cancelledflightId
- The ID of the flight for which the booking is to be cancelled
-
-
Method Details
-
execute
public void execute(FlightBookingSystem flightBookingSystem) throws FlightBookingSystemException, IOException Executes the CancelBooking command within the provided FlightBookingSystem instance. Cancels the booking of the specified customer on the specified flight by invoking the cancelBooking method on flightBookingSystem. After cancellation, the updated booking data is stored using FlightBookingSystemData.- Specified by:
execute
in interfaceCommand
- Parameters:
flightBookingSystem
- The FlightBookingSystem instance on which the booking cancellation is to be executed- Throws:
FlightBookingSystemException
- If there is an issue cancelling the booking in the systemIOException
- If there is an error storing data using FlightBookingSystemData
-