Class AddCustomer
java.lang.Object
bcu.cmp5332.bookingsystem.commands.AddCustomer
- All Implemented Interfaces:
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);
-
Field Summary
Fields inherited from interface bcu.cmp5332.bookingsystem.commands.Command
HELP_MESSAGE
-
Constructor Summary
ConstructorDescriptionAddCustomer
(String name, String phone, String email) Constructs an AddCustomer command with the specified name, phone number, and email address. -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(FlightBookingSystem flightBookingSystem) Executes the AddCustomer command within the provided FlightBookingSystem instance.
-
Constructor Details
-
AddCustomer
Constructs an AddCustomer command with the specified name, phone number, and email address.- Parameters:
name
- The name of the customerphone
- The phone number of the customeremail
- 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 interfaceCommand
- 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 systemIOException
- If there is an error storing data using FlightBookingSystemData
-