All pastes #438163 Raw Edit

Miscellany

public java v1 · immutable
·published 2007-04-13 13:44 UTC
rendered paste body
import java.util.List;import java.util.ArrayList;import java.util.Iterator;public class Bank{    List advisorList;    List bankAccountList;        public Bank()    {       this.advisorList = new ArrayList();       this.bankAccountList = new ArrayList();           }        public static Bank getInstance()    {    	return new Bank();    }        //* 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);    	    }   }