All pastes #419573 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-04-01 13:08 UTC
rendered paste body
import java.util.List;
import java.util.ArrayList;

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)
    {

        for(int i=0; i< this.bankAccountList.size(); i++)
        {

               BankAccount check = (BankAccount) this.bankAccountList.get(i) ;
               if(check.getAccountNumber() == accountNum)
               {
                   return check;
               }
        }
        return null;
    }
    
    //* return an account by it's owners last name
    public BankAccount getAccountByName(String lastName)
    {

        for(int i=0; i< this.bankAccountList.size(); i++)
        {

               BankAccount check = (BankAccount) this.bankAccountList.get(i);
               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);
    }
    
    public List showAdvisor()
    {
    	return advisorList;
    }
    
    public void addAdvisor(Advisor advisor)
    {
    	advisorList.add(advisor);

    }
    
   
}