Bank and subclasses HashBank and TreeBank that behave as described below. You will also need classes BankAccount, SavingsAccount, and CheckingAccount. These classes are to behave as in Assignment 8, except that:
Bank class is to be an abstract class with an abstract method getSortedAccountList()
with return type List<BankAccount>. Subclasses are to define this method to return a list of BankAccounts sorted by the name of the account holder.
Bank class is to represent its collection of accounts by a Map from the String to the BankAccount class. That is, the bank accounts are to be indexed by the name of their account holders.
Bank class is to take as arguments an empty Map of Strings to Bankaccounts, and an interest rate. The interest rate is to be the interest rate for the savings accounts of the bank. The Map argument is to serve as the initial collection 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 TreeBank constructor is to invoke this constructor with an empty TreeMap as the first argument, and the HashBank constructor is to invoke this constructor with an empty HashMap as the first argument.
Bank class methods addAccount, getAccount, removeAccount, payInterest, getTotalBalance, and getNumberOfAccounts are to work as before, except that they are to use indicated Map class rather than a List class as arguments.
Bank class is to have a nonabstract method getAccountList() with return type List<BankAccount> that returns a list of all the accounts in the bank. This list need not be sorted; this method is to work as quickly as possible.
Bank class is to have a nonabstract method getAccountListSortedByBalance() that returns a copy of the list of the bank's accounts that is sorted by nonincreasing balance and that (for full credit) invokes the two-argument version of Collections.sort. Note that this method requires a Comparator object as argument.
Bank class need not have a method getKthAccount.
BankAccount class is to implement correctly the Comparable interface. The compareTo method is to compare the names of account holders as Strings.
BankAccount class is to define an equals method.
ClassCastExceptions should be documented with a Javadoc @throws tag. Null arguments should be dealt with by throwing a NullPointerException from constructors and dealt with directly in the addAccount method. You do not need to document any NullPointerException with a Javadoc @throws tag.
For this assignment, you are to turn in hard and soft copies of your class definitions, as well as a hard copy of the results of testing with (the main method of) the class A9.java, available from the class web site. If you create your class definitions by modifying old definitions of the classes, you needn't bother removing methods that are not required in this assignment. As always, you may add any additional methods or classes that you find useful.