public abstract class AbstractBankAccount extends Object
Modifier | Constructor and Description |
---|---|
protected |
AbstractBankAccount(long balance)
Create a bank account with the given starting balance.
|
Modifier and Type | Method and Description |
---|---|
void |
deposit(long amount)
Deposit an amount of currency into the account.
|
long |
getBalance()
Return the account balance.
|
abstract void |
update()
Update the account balance to reflect specific policies on the account;
for example, a savings account might add interest to the account
balance.
|
void |
withdraw(long amount)
Withdraw an amount of currency from the account.
|
protected AbstractBankAccount(long balance)
balance
- the starting balance of the accountpublic void deposit(long amount)
Exactly how the balance of the account is affected by the deposit is determined by the subclasses; the default behavior supplied by AbstractBankAccount is to add the deposit amount to the balance.
IllegalArgumentException
- if amount < 0
amount
- the amount of currency to deposit into the accountpublic void withdraw(long amount)
Exactly how the balance of the account is affected by the withdrawal is determined by the subclasses; the default behavior supplied by AbstractBankAccount is to subtract the withdrawal amount from the balance.
IllegalArgumentException
- if amount < 0
amount
- the amount of currency to withdraw from the accountpublic long getBalance()
public abstract void update()
d
- the date when the update is performed