Apache Financial Services

Simple Bank : Interfaces

The Simple Bank interfaces define a simplistic Bank from which multiple Account instances can be created and removed.

Bank Interface

The Bank interface services as a factory for accounts. Using the Bank, clients can create and destroy accounts.

Bank.java

package org.apache.bank;

public interface Bank
{
   /**
    * Create, register and return a new account.
    * @param name the name of the account holder
    * @return Account the account
    */
    Account createAccount( String name );

   /**
    * Returns an account based on a supplied account number.
    * @param id the account number
    * @return Account the bank account
    */
    Account getAccount( int id ) throws NoSuchAccountException;

   /**
    * Close an account.
    * @param id the account number
    */
    void closeAccount( int id ) throws PolicyException, NoSuchAccountException;

   /**
    * Get the number of accounts managed by the bank.
    * @return the number of accounts
    */
    int accounts();

}

Account Interface

The Account interface encapsulates the services that a client can perform against an account - deposit of funds, withdrawls, and account balance queries.

Account.java

package org.apache.bank;

public interface Account
{
   /**
    * Get the account name.
    * @return the account name
    */
    String getName();

   /**
    * Get the account number.
    * @return the account number
    */
    int getID();

   /**
    * Get the account balance.
    * @return the account balance
    */
    float getBalance();

   /**
    * Deposit funds into the account.
    * @param amount the amount of funds to deposit
    */
    void deposit( float amount );

   /**
    * Withdraw funds from the account.
    * @param amount the amount of funds to withdraw
    */
    void withdraw( float amount ) throws InsufficientFundsException;

}