|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jwalk.test.Wallet
public class Wallet
Wallet is a simple purse accepting and disbursing money payments.
This is a standard test class, provided with the JWalk tool suite.
The Wallet stores an integer balance and accepts requests to pay in, or
pay out, sums of money. Only positive integer amounts are permitted. The
Wallet may reject a request to pay out more than the balance contained.
This test class can be used to demonstrate the ability of an AlgebraWalker
to discover the algebraic structure of a Wallet data type, in less than
ideal conditions. This is because the transformer payOut()
only modifies the object for some invocations (if the amount can actually
be paid) and otherwise masquerades as an observer, returning a boolean
result. Similarly, the primitive payIn()
method masquerades
as a transformer, when the resulting balance has been seen before (as a
result of a debit in the prefix).
This test class can also be used to demonstrate the ability of a
StateSpaceWalker to discover the high-level state space of a Wallet data
type, in less than ideal conditions. This is because the state space does
not use the full boolean product of predicate outcomes, and the predicates
are not mutually independent. Wallet therefore has no Default state, and
no state when both predicates are true simultaneously.
Constructor Summary | |
---|---|
Wallet()
Creates a new Wallet with a balance of zero. |
Method Summary | |
---|---|
boolean |
inCredit()
Reports whether this Wallet has some money left. |
boolean |
isEmpty()
Reports whether this Wallet has no money left. |
int |
money()
Returns the balance of the money in the Wallet. |
void |
payIn(int amount)
Pays in an amount of money. |
boolean |
payOut(int amount)
Pays out an amount of money, if the Wallet can support this. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Wallet()
Method Detail |
---|
public void payIn(int amount)
amount
- the amount to pay in.
java.lang.IllegalArgumentException
- if the amount is zero or negative.public boolean payOut(int amount)
amount
- the amount to pay out.
public int money()
public boolean isEmpty()
public boolean inCredit()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |