|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Bank
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.
It is persistent: it can save its state to a file and read it
back at a later time.
To create a Bank and open it for business issue the command
java Bank
with appropriate arguments.
BankAccount
,
Serialized FormConstructor Summary | |
Bank(String bankName)
Construct a Bank with the given name. |
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 |
setAtm(Terminal atm)
Set the atm for this 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 |
public Bank(String bankName)
bankName
- the name for this Bank.Method Detail |
public void countTransaction()
public int getBalance()
public int getCheckFee()
public double getInterestRate()
public int getMaxFreeTransactions()
public int getMonthlyCharge()
public int getNumberOfAccounts()
public int getTransactionCount()
public int getTransactionFee()
public void incrementBalance(int amount)
amount
- the amount increment.public static void main(String[] args)
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.inThe -f argument reads the bank's state from the specified file, and writes it to that file when the program exits.
args
- the command line arguments:
-e echo input. -f filename bankName any other command line argument.
public void setAtm(Terminal atm)
atm
- the Bank's atm.public void visit()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |