Class ApplyPromocode
java.lang.Object
bcu.cmp5332.bookingsystem.commands.ApplyPromocode
- All Implemented Interfaces:
Command
The ApplyPromocode class represents a command to apply a promotional code to a flight
in the flight booking system.
The promotional code is applied to a flight identified by its booking ID. Upon execution, the system retrieves the booking with the specified ID, applies the promotional code to its associated flight, and stores the updated data using FlightBookingSystemData.
Example usage:
int bookingID = 21;
String promocode = "nabinOpensFlightCompany20";
Command applyPromocodeCommand = new ApplyPromocode(bookingID, promocode);
applyPromocodeCommand.execute(flightBookingSystem);
-
Field Summary
Fields inherited from interface bcu.cmp5332.bookingsystem.commands.Command
HELP_MESSAGE
-
Constructor Summary
ConstructorDescriptionApplyPromocode
(int bookingID, String promocode) Constructs an ApplyPromocode command with the specified booking ID and promotional code. -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(FlightBookingSystem flightBookingSystem) Executes the ApplyPromocode command within the provided FlightBookingSystem instance.
-
Constructor Details
-
ApplyPromocode
Constructs an ApplyPromocode command with the specified booking ID and promotional code.- Parameters:
bookingID
- The booking ID of the flight to apply the promocodepromocode
- The promotional code to apply
-
-
Method Details
-
execute
public void execute(FlightBookingSystem flightBookingSystem) throws FlightBookingSystemException, IOException Executes the ApplyPromocode command within the provided FlightBookingSystem instance. Retrieves the booking with the specified ID, applies the promotional code to its associated flight, and stores the updated data using FlightBookingSystemData.- Specified by:
execute
in interfaceCommand
- Parameters:
flightBookingSystem
- The FlightBookingSystem instance on which the promocode is to be applied- Throws:
FlightBookingSystemException
- If there is an issue applying the promocode to the flightIOException
- If there is an error storing data using FlightBookingSystemData
-