Class AddCustomer

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

public class AddCustomer extends Object implements Command
The AddCustomer class represents a command to add a new customer to the flight booking system. It implements the Command interface and requires execution within a FlightBookingSystem instance.

The customer is identified by their name, phone number, and email address. Upon execution, the system assigns a unique ID to the new customer, adds them to the system, and stores the updated data using FlightBookingSystemData.

Example usage:


 String name = "John Doe";
 String phone = "1234567890";
 String email = "[email protected]";
 Command addCustomerCommand = new AddCustomer(name, phone, email);
 addCustomerCommand.execute(flightBookingSystem);
 
  • Constructor Details

    • AddCustomer

      public AddCustomer(String name, String phone, String email)
      Constructs an AddCustomer command with the specified name, phone number, and email address.
      Parameters:
      name - The name of the customer
      phone - The phone number of the customer
      email - The email address of the customer
  • Method Details

    • execute

      public void execute(FlightBookingSystem flightBookingSystem) throws FlightBookingSystemException, IOException
      Executes the AddCustomer command within the provided FlightBookingSystem instance. Generates a unique ID for the new customer, creates a Customer object with the provided name, phone number, email, and adds it to the system using flightBookingSystem. The updated system data is then stored using FlightBookingSystemData.
      Specified by:
      execute in interface Command
      Parameters:
      flightBookingSystem - The FlightBookingSystem instance on which the customer is to be added
      Throws:
      FlightBookingSystemException - If there is an issue adding the customer to the system
      IOException - If there is an error storing data using FlightBookingSystemData