public abstract class Account
extends java.lang.Object
AccountData
and the temporary proxy
objects OfflineAccountProxy
. This class provides
infrastructure for storing lists of transactions and some standard
implementations of account methods.Modifier and Type | Field and Description |
---|---|
int |
accountNumber
Account number of the account represented by
this object
TODO: replace public with private; this seems to be a problem with the
JML-DL translation (accountNumber is not visible in JML specs for
subclasses if the Java visibility is private) |
TransactionList |
transactions
A list of transactions in which the most recent transaction is the first
element
|
Modifier | Constructor and Description |
---|---|
protected |
Account(int accountNumber) |
Modifier and Type | Method and Description |
---|---|
abstract int |
accountBalance() |
protected void |
addTransaction(Transaction trance)
Add a transaction
trance to the list of stored transaction |
abstract boolean |
balanceIsAccessible() |
int |
checkAndWithdraw(int amount)
Try to withdraw
amount from the account with checking
whether this is possible, return the amount of money that is given out |
protected void |
flushTransactions()
Remove all transactions that have been pushed using
addTransaction |
int |
getAccountNumber() |
protected TransactionList |
getTransactions()
Get all transactions that have been performed for this account.
|
abstract boolean |
newWithdrawalIsPossible(int amount)
Determine whether a certain amount of money may be withdrawn.
|
abstract void |
requestStatement()
Request a printed account statement.
|
protected java.lang.String |
transactionListToString()
Helper method, used by the two subclasses of this class for implementing
toString |
abstract void |
withdraw(int amount)
Withdraw
amount from the account |
public final int accountNumber
this
object
TODO: replace public with private; this seems to be a problem with the
JML-DL translation (accountNumber is not visible in JML specs for
subclasses if the Java visibility is private)public TransactionList transactions
public abstract void withdraw(int amount)
amount
from the accountamount
- the amount to be withdrawnpublic int checkAndWithdraw(int amount)
amount
from the account with checking
whether this is possible, return the amount of money that is given outamount
- the amount to be withdrawnamount
if the withdrawal was successful,
0
otherwisepublic abstract void requestStatement()
public abstract boolean balanceIsAccessible()
true
iff the balance of this account can be
determined (not possible for the offline situation)public abstract int accountBalance()
public abstract boolean newWithdrawalIsPossible(int amount)
PermanentAccount.withdraw(int,int)
it is possible to
circumvent this check, which is necessary because for offline withdrawals
the balance cannot be accessed and checkedamount
- the amount of money requestedtrue
iff amount
can be withdrawn
from the accountpublic int getAccountNumber()
this
objectprotected void addTransaction(Transaction trance)
trance
to the list of stored transactiontrance
- the transaction to be addedprotected TransactionList getTransactions()
protected void flushTransactions()
addTransaction
protected java.lang.String transactionListToString()
toString
getTransactions