import java.util.*;

/**
 * Bank.java
 *
 *
 * Created: Wed Sep 18 22:10:45 2002
 *
 * @author <a href="mailto: "</a>
 * @version
 */

public class Bank {
   ArrayList accounts;
   static int aNo = 123450;
   public Bank (){
      accounts = new ArrayList();
   }

   public int createAccount(double amt, String name)
   {
      aNo++;
      accounts.add(new Account(aNo, name, amt));
      return aNo;
   }
   // Code for delegation of Account methods to accounts
   
   /**
    *
    * @param1 acct <Account number>
    * @param2 amt <amount to deposit>
    * @see Account#deposit(double)
    */
   public void deposit(int acct, double amt) {
      Account current = locate(acct);
      current.deposit(amt);
   }
   
   /**
    *
    * @param1 acct <Account number>
    * @param2 amt <amount to withdraw>
    * @return <balance>
    * @exception InsufficientFundsException <description>
    * @see Account#withdraw(double)
    */
   public double withdraw(int acct, double amt) throws InsufficientFundsException {
      Account current = locate(acct);      
      return current.withdraw(amt);
   }
   
   /**
    *
    * @param1 acct <Account number>
    * @return <description>
    * @see Account#inquireBalance()
    */
   public double inquireBalance(int acct) {
      Account current = locate(acct);
      return current.inquireBalance();
   }

   public Account locate(int acct)
   {  Account x;
      ListIterator l = accounts.listIterator();
	 x = (Account)l.next();
      while (!(x.matchAcctNum(acct)))
      {
	 x = (Account)l.next();
      }
      return x;
   }
      

}// Bank







