Bank and subclasses ArrayBank and LinkedBank that behave as described below. You will also need classes BankAccount, SavingsAccount, and CheckingAccount that behave as in Chapter 10 of the text, except as noted below. Note that most of the required methods of the Bank class as well as the account classes appear in the text or in the solutions to earlier assignments, and may be freely used with appropriate credit.
The Bank class and its subclasses are each to maintain a List of BankAccounts. However for the ArrayBank class this List is to be an ArrayList, while for the LinkedBank class this List is to be a LinkedList.
The Bank class is to have a constructor that takes as arguments an empty List of accounts and an interest rate. The interest rate is to be the interest rate for the savings accounts of the bank. The List argument is to serve as the initial list of accounts (of whatever type) of the bank. If the argument to this constructor is not empty, the constructor is to throw an appropriate IllegalArgumentException object. The ArrayBank constructor is to invoke this constructor with an empty ArrayList as the first argument, and the LinkedBank constructor is to invoke this constructor with an empty LinkedList as the first argument.
The Bank class is also to have the following public methods:
addAccount, which takes a BankAccount and adds a clone of the account to the bank if it is not null, and if there is no existing account with an account holder of the same name. It is to return true if the account was added, and false otherwise. Note that this behavior implies that no account holder can have two accounts even if they are of different types.
removeAccount, which takes an account holder name represented as a String, and removes the account with that name from the bank, if one exists. It is to return true if the account was removed, and false otherwise.
getAccount, which takes an account holder name represented as a String, and returns a clone of the bank's account with that name, if one exists. Otherwise it is to return null. The return type of this method is to be BankAccount.
getKthAccount, which takes an integer k and returns a clone of the bank's kth account if one exists. Otherwise it is to return null. The return type of this method is to be BankAccount.
payInterest, which invokes the payInterest method described below for each account in the bank.
getNumberOfAccounts, which returns the number of accounts currently in the bank.
getTotalBalance, which takes no argument and returns the sum of the balances of all the accounts.
BankAccount class is to have an additional instance field accountHolder of class String, with an accessor getAccountHolder().
BankAccount class is to have a do-nothing payInterest method that takes an interest rate as parameter. As in Chapter 10, this parameter is to represent the interest rate in percent.
SavingsAccount account class is to override the payInterest() method with a method that behaves as the SavingsAccount.addInterest() method of Chapter 10 of the text, except that it takes the interest rate as parameter. Note that this means that the interest rate instance field of the text's SavingsAccount class is unnecessary.
BankAccount class is to have a properly defined clone method. The text of such a definition is given in Advanced Topic 10.6 of the text. Don't forget to have your class implement the Cloneable interface.
main method of) the class A8.java, available from the class web site. If you create your class definitions by modifying old definitions of the classes, you may, but you needn't, remove methods that are not required in this assignment. As always, you may add any additional methods or classes that you find useful.