Class DeleteCustomer

java.lang.Object
bcu.cmp5332.bookingsystem.commands.DeleteCustomer
All Implemented Interfaces:
Command

public class DeleteCustomer extends Object implements 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

    Constructors
    Constructor
    Description
    DeleteCustomer(int customerID)
    Constructs a DeleteCustomer command object with the specified customer ID.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    execute(FlightBookingSystem flightBookingSystem)
    Executes the delete customer command within the provided FlightBookingSystem instance.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 interface Command
      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