import java.util.List; import java.util.ArrayList; import java.util.Iterator; public class Bank { List advisorList = new ArrayList(); List bankAccountList = new ArrayList(); private Bank() { } public static synchronized Bank getInstance() { if (ref == null) ref = new Bank(); return ref; } public Object clone() throws CloneNotSupportedException { throw new CloneNotSupportedException(); } private static Bank ref; //* return an account by it's account number public BankAccount getAccountByNumber(int accountNum) { Iterator itAccountByNumber = bankAccountList.iterator(); while(itAccountByNumber.hasNext()) { BankAccount check = (BankAccount)itAccountByNumber.next(); if(check.getAccountNumber() == accountNum) { return check; } } return null; } //* Given a customers last name return the account number public BankAccount getAccountByName(String lastName) { Iterator itAccountByName = bankAccountList.iterator(); while(itAccountByName.hasNext()) { BankAccount check = (BankAccount)itAccountByName.next(); List clients = check.getCustomerList(); for(Object o : clients) { Customer c = (Customer) o; if(c.getLastName().equals(lastName)) { return check; } } } return null; } //* deposit money into a BankAccount public void deposit(BankAccount b, double amt) { b.deposit(amt); } public void withdraw(BankAccount b, double amt) { b.withdraw(amt); } //Print all advisors in the advisorList public List showAdvisor() { Iterator itAdvisor = advisorList.iterator(); while (itAdvisor.hasNext()) { Advisor a = (Advisor)itAdvisor.next(); System.out.println("======================"); System.out.println(a); System.out.println("======================"); } return null; } public void addAdvisor(Advisor advisor) { advisorList.add(advisor); } public void addBankAccount(BankAccount b) { bankAccountList.add(b); } }