|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
codesimian.NeedLiquid
public class NeedLiquid
A Liquid contains an amount (type double) and a name (type String).
When a NeedLiquid is thrown, a Runnable is given so execution can continue after the Liquid is given.
A NeedLiquid requires a specific amount of Liquid before the Runnable will be run.
You can not get the Runnable from a NeedLiquid because then code could cheat by running it directly.
| Nested Class Summary | |
|---|---|
static class |
NeedLiquid.Failed
needed a certain amount and name of Liquid, but could not get it, and it is too late to pay that now. |
| Field Summary | |
|---|---|
double |
D
|
java.lang.String |
name
|
| Constructor Summary | |
|---|---|
protected |
NeedLiquid()
|
|
NeedLiquid(java.lang.String liquidName,
double needThisMuchMoreLiquid,
java.lang.Runnable continueExecution)
|
protected |
NeedLiquid(java.lang.String message,
java.lang.Runnable continueExecution)
|
| Method Summary | |
|---|---|
boolean |
canContinue()
Returns true if would continues if the Liquid(s) described by this NeedLiquid are put into this NeedLiquid. |
boolean |
hasLiquid()
has this NeedLiquid been paid all the Liquid it requires? |
int |
liquidCount()
|
void |
run()
throws this if hasLiquid() is false, else runs the inner Runnable |
void |
takeLiquid(Liquid liq)
liq.amount() must >= this.liquidAmount |
void |
takeLiquidThenRun(Liquid liq)
throws this if liq.amount() < this.liquidAmount OR liq.name is not this.liquidName |
| Methods inherited from class java.lang.Throwable |
|---|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final java.lang.String name
public final double D
| Constructor Detail |
|---|
protected NeedLiquid()
protected NeedLiquid(java.lang.String message,
java.lang.Runnable continueExecution)
public NeedLiquid(java.lang.String liquidName,
double needThisMuchMoreLiquid,
java.lang.Runnable continueExecution)
| Method Detail |
|---|
public boolean canContinue()
public int liquidCount()
public void takeLiquidThenRun(Liquid liq)
throws NeedLiquid
NeedLiquidpublic void takeLiquid(Liquid liq)
public boolean hasLiquid()
public void run()
throws NeedLiquid
run in interface java.lang.RunnableNeedLiquid
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||