Class DeleteCustomer
java.lang.Object
bcu.cmp5332.bookingsystem.commands.DeleteCustomer
- All Implemented Interfaces:
Command
The DeleteCustomer class represents a command to delete a customer 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 customer with the specified ID is marked as deleted by setting the 'deleted' flag. The modified system data is then stored using FlightBookingSystemData.
If the customer with the specified ID does not exist in the system, a FlightBookingSystemException is thrown.
Example usage:
// Create a new DeleteCustomer command instance for customer with ID 101
Command deleteCustomerCommand = new DeleteCustomer(101);
// Execute the command within a FlightBookingSystem instance
deleteCustomerCommand.execute(flightBookingSystem);
- See Also:
-
Field Summary
Fields inherited from interface bcu.cmp5332.bookingsystem.commands.Command
HELP_MESSAGE
-
Constructor Summary
ConstructorDescriptionDeleteCustomer
(int customerID) Constructs a DeleteCustomer command object with the specified customer ID. -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(FlightBookingSystem flightBookingSystem) Executes the delete customer command within the provided FlightBookingSystem instance.
-
Constructor Details
-
DeleteCustomer
public DeleteCustomer(int customerID) Constructs a DeleteCustomer command object with the specified customer ID.- Parameters:
customerID
- The ID of the customer to be deleted
-
-
Method Details
-
execute
public void execute(FlightBookingSystem flightBookingSystem) throws FlightBookingSystemException, IOException Executes the delete customer command within the provided FlightBookingSystem instance. Marks the customer with the specified ID as deleted by setting the 'deleted' flag.- 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 customer (e.g., customer not found)IOException
- If there is an error storing data using FlightBookingSystemData
-