YournameLab8.java
Customer.java
1. Start NetBeans.
2. Create a new project called YournameLab8 with your name.
3. Create a Java class file for a Customer class.
4. Implement the Customer class.
(a) Add the following private instance variables to the Customer class:
(b) Add public accessor and mutator methods for each of the instance variables.
(c) Add the following public methods to the Customer class:
First Name: Annie
Last Name: Malone
Email: amalone@poro.edu
5. Write a code in the main method of your main class to test the Customer class.
(a) Create a new Customer object called customer1.
(b) Call the readInput method on customer1.
(c) Call the writeOutput method on customer1.
(d) The output should look something like this:
Enter the customer first name:
Meg
Enter the customer last name:
Whitman
Enter the customer email address:
mwhitman@hp.com
First Name: Meg
Last Name: Whitman
Email: mwhitman@hp.com
6. Add some Boolean-valued methods to the Customer class.
(a) Add a private boolean-valued method hasSameNameAs with a parameter of type Customer that returns true if the first and last name of the object method is called on are identical to the first and last name of the parameter, and returns false otherwise.
(b) Add a private boolean-valued method called hasSameEmailAs with a parameter of type Customer that returns true if the email of the object the method was called on is the same as the email of the parameter ignoring case.
(c) Add a public boolean-valued method called equals with a parameter of type Customer that returns true if:
Otherwise, it should return false.
7. Write code in your main method to test out the equals method and the == operator onCustomer objects.
(a) Create a second customer object called customer2.
(b) Call readInput on customer2.
(c) Call writeOutput on customer2.
(d) Use the operator == to compare customer1 and customer2 and output one of the following messages depending on the result:
Customer1 is equal to customer2 using the == operator
Customer1 is not equal to customer2 using the == operator
(e) Use the equals method to compare customer1 and customer2 and output one of the following messages depending on the result:
Customer1 is equal to customer2 using the equals method
Customer1 is not equal to customer2 using the equals method
8. Test your code on multiple inputs to see how it behaves.
(a) Test the program with two customers with different names and email addresses.
(b) Test the program with two customer with identical names and the same email addresses.
(c) Test the program with two customers and identical names but with the first email address in uppercase and the second in lower case.
9. Write code in your main method to see what happens when one variable of class type is assigned to another variable of class type.
(a) Assign customer2 to customer1 object using the assignment operator =.
(b) Use the operator == to compare customer1 and customer2 and output the message indicating the result.
(c) Use the setEmail method to change the email address of customer2 to nobody@nowhere.com.
(d) Use the writeOutput method to display customer1.
(e) Test your code to see what happens.