Class DeleteFlight
java.lang.Object
bcu.cmp5332.bookingsystem.commands.DeleteFlight
- All Implemented Interfaces:
Command
The DeleteFlight class represents a command to delete a flight from the flight booking system.
It implements the Command interface, allowing it to be executed within the context of a FlightBookingSystem instance.
Upon execution, the flight with the specified flight number is removed from the system. The modified system data is then stored using FlightBookingSystemData.
If the flight with the specified flight number does not exist in the system, a FlightBookingSystemException is thrown.
Example usage:
// Create a new DeleteFlight command instance for flight with number "FL123"
Command deleteFlightCommand = new DeleteFlight("FL123");
// Execute the command within a FlightBookingSystem instance
deleteFlightCommand.execute(flightBookingSystem);
- See Also:
-
Field Summary
Fields inherited from interface bcu.cmp5332.bookingsystem.commands.Command
HELP_MESSAGE
-
Constructor Summary
ConstructorDescriptionDeleteFlight
(int flightNumber) Constructs a DeleteFlight command object with the specified flight number. -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(FlightBookingSystem flightBookingSystem) Executes the delete flight command within the provided FlightBookingSystem instance.
-
Constructor Details
-
DeleteFlight
public DeleteFlight(int flightNumber) Constructs a DeleteFlight command object with the specified flight number.- Parameters:
flightNumber
- The number of the flight to be deleted
-
-
Method Details
-
execute
public void execute(FlightBookingSystem flightBookingSystem) throws FlightBookingSystemException, IOException Executes the delete flight command within the provided FlightBookingSystem instance. Removes the flight with the specified flight number from the system.- Specified by:
execute
in interfaceCommand
- Parameters:
flightBookingSystem
- The FlightBookingSystem instance on which the command is executed- Throws:
FlightBookingSystemException
- If there is an issue with deleting the flight (e.g., flight not found)IOException
- If there is an error storing data using FlightBookingSystemData
-