Class Bank

java.lang.Object
  extended byBank

public class Bank
extends Object

A Bank object simulates the behavior of a simple bank/ATM. It contains a Terminal object and a collection of BankAccount objects. Its public method visit opens this Bank for business, prompting the customer for input. To create a Bank and open it for business issue the command java Bank.

Version:
4
See Also:
BankAccount

Constructor Summary
Bank(String bankName, Terminal atm)
          Construct a Bank with the given name and Terminal.
 
Method Summary
 void countTransaction()
          Increment by one the count of transactions, for this bank.
 int getBalance()
          Get the current bank balance.
 int getNumberOfAccounts()
          Get the current number of open accounts.
 int getTransactionCount()
          Get the number of transactions performed by this bank.
 void incrementBalance(int amount)
          Increment bank balance by given amount.
static void main(String[] args)
          Run the simulation by creating and then visiting a new Bank.
 void visit()
          Simulates interaction with a Bank.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bank

public Bank(String bankName,
            Terminal atm)
Construct a Bank with the given name and Terminal.

Parameters:
bankName - the name for this Bank.
atm - this Bank's Terminal.
Method Detail

countTransaction

public void countTransaction()
Increment by one the count of transactions, for this bank.


getBalance

public int getBalance()
Get the current bank balance.

Returns:
current bank balance.

getNumberOfAccounts

public int getNumberOfAccounts()
Get the current number of open accounts.

Returns:
number of open accounts.

getTransactionCount

public int getTransactionCount()
Get the number of transactions performed by this bank.

Returns:
number of transactions performed.

incrementBalance

public void incrementBalance(int amount)
Increment bank balance by given amount.

Parameters:
amount - the amount increment.

main

public static void main(String[] args)
Run the simulation by creating and then visiting a new Bank.

A -e argument causes the input to be echoed. This can be useful for executing the program against a test script, e.g.,

   java Bank -e < Bank.in
 

Parameters:
args - the command line arguments:
         -e echo input.
         bankName any other command line argument.
         

visit

public void visit()
Simulates interaction with a Bank. Presents the user with an interactive loop, prompting for banker transactions and in case of the banker transaction "customer", an account id and further customer transactions.