Individual Assignment 3 Solution



To be able to work on this assignment, you will need a functional version of the BankAccount class from last week’s assignment. Your first task is to get this working.

For this assignment, you are expected to infer some of the requirements from the unit tests. This includes string formats, exact names of methods, the order or arguments and the constructors required.

Create a Customer class with the following:

  • Instance variables with appropriate getter and setter methods: name, which is a String, and a customerID, which is an integer.

  • A toString() method which provides a well-formatted string representation of the instance variables in the Customer class.

  • Appropriate constructors for the class.

Update BankAccount class to:

  • Add an instance of the Customer class to your BankAccount class as an instance variable with a getter and setter method. The name of the instance variable should be accountHolder.

  • Add appropriate constructors to allow creation of bank accounts to specify an account holder.

  • Update the toString method such that the string returned includes account holder information.

  • Add a method called transfer that takes an amount to transfer and an account to transfer to as arguments. The transfer should only take place if the account has enough funds.

A JUnit test is provided below for both the updated BankAccount class (20 tests) and the Customer class (5 tests). To qualify for the full team grade you must pass at least 20/25 tests.

error: Content is protected !!