Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create a new IntelliJ project and paste in the attached file Cutomer.java .

  2. Look at the class definition and notice (only notice, follow the instructions below to actually fill the code in) the comments that indicate where you should add your code. Notice that the existing constructor takes a single argument to set the customer’s name, and does not update the account number. Every customer will have their account set to zero.

  3. Create a CustomerApplication.java class with a main method. Create a couple of instances of Customer class and test how they work. Anything surprising?

  4. In the Customer class definition, declare another private instance variable to hold the customer's status as char , provide an accessor method - isHeld() - which returns true if the status is equal to 'H', otherwise false. Also provide getStatus() method that returns the char.

  5. Define a second constructor that has two arguments to initialise the customer’s status as well as their name. If the value received is not ‘A’ or ‘I’ or ‘H’ (for active, inactive or on-hold), then set it to ‘H’. Remember that you can use this() to avoid duplicating code in multiple constructors. Modify the first constructor (which does not receive a char argument) to set the status to ‘A’.

  6. Save the project and fix any compiler errors before proceeding. Write up some code in your main method to prove that your code is working correctly.

...