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. The visit method 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:
7
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 getCheckFee()
          The charge this bank levies for cashing a check.
 double getInterestRate()
          The current interest rate on savings.
 int getMaxFreeTransactions()
          The number of free transactions per month.
 int getMonthlyCharge()
          The charge this bank levies each month.
 int getNumberOfAccounts()
          Get the current number of open accounts.
 int getTransactionCount()
          Get the number of transactions performed by this bank.
 int getTransactionFee()
          The charge this bank levies for a transaction.
 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.

getCheckFee

public int getCheckFee()
The charge this bank levies for cashing a check.

Returns:
check fee

getInterestRate

public double getInterestRate()
The current interest rate on savings.

Returns:
the interest rate

getMaxFreeTransactions

public int getMaxFreeTransactions()
The number of free transactions per month.

Returns:
the number of transactions

getMonthlyCharge

public int getMonthlyCharge()
The charge this bank levies each month.

Returns:
the monthly charge

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.

getTransactionFee

public int getTransactionFee()
The charge this bank levies for a transaction.

Returns:
the transaction fee

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 the case of the banker transaction "customer", an account id and further customer transactions.