Class BankAccount

java.lang.Object
  extended byBankAccount

public class BankAccount
extends Object

A BankAccount object has private fields to keep track of its current balance, the number of transactions performed and the Bank in which it is an account, and and public methods to access those fields appropriately.

Version:
4
See Also:
Bank

Constructor Summary
BankAccount(int initialBalance, Bank issuingBank)
          Construct a BankAccount with the given initial balance and issuing Bank.
 
Method Summary
 void countTransaction()
          Increment by 1 the count of transactions, for this account and for the issuing Bank.
 int deposit(int amount)
          Deposit the given amount, increasing this BankAccount's balance and the issuing Bank's balance.
 int getBalance()
          Get the current balance.
 Bank getIssuingBank()
          Get the bank that issued this account.
 int getTransactionCount()
          Get the number of transactions performed by this account.
 void incrementBalance(int amount)
          Increment account balance by given amount.
 int requestBalance()
          Request for balance.
 int withdraw(int amount)
          Withdraw the given amount, decreasing this BankAccount's balance and the issuing Bank's balance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BankAccount

public BankAccount(int initialBalance,
                   Bank issuingBank)
Construct a BankAccount with the given initial balance and issuing Bank. Construction counts as this BankAccount's first transaction.

Parameters:
initialBalance - the opening balance.
issuingBank - the bank that issued this account.
Method Detail

countTransaction

public void countTransaction()
Increment by 1 the count of transactions, for this account and for the issuing Bank. Does NOT count as a transaction.


deposit

public int deposit(int amount)
Deposit the given amount, increasing this BankAccount's balance and the issuing Bank's balance. Counts as a transaction.

Parameters:
amount - the amount to be deposited
Returns:
amount deposited

getBalance

public int getBalance()
Get the current balance. Does NOT count as a transaction.

Returns:
current account balance

getIssuingBank

public Bank getIssuingBank()
Get the bank that issued this account. Does NOT count as a transaction.

Returns:
issuing bank.

getTransactionCount

public int getTransactionCount()
Get the number of transactions performed by this account. Does NOT count as a transaction.

Returns:
number of transactions performed.

incrementBalance

public void incrementBalance(int amount)
Increment account balance by given amount. Also increment issuing Bank's balance. Does NOT count as a transaction.

Parameters:
amount - the amount increment.

requestBalance

public int requestBalance()
Request for balance. Counts as a transaction.

Returns:
current account balance

withdraw

public int withdraw(int amount)
Withdraw the given amount, decreasing this BankAccount's balance and the issuing Bank's balance. Counts as a transaction.

Parameters:
amount - the amount to be withdrawn
Returns:
amount withdrawn