|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Toilet
This class approximates the standard interface to a physical toilet. The current implementation is a stub that mostly just prints stuff. We could replace it later with a more detailed implementation that manipulates the chain, the siphon jet, the ball float, the filler valve, etc. All of these would be handled with private methods and variables, because the user shouldn't have to know how the toilet works in order to use it.
Field Summary | |
private static float |
CLOG_PROBABILITY
Probability that the toilet will clog and overflow if you try to flush TrashWaste. |
protected Waste |
contents
Whatever's in the toilet. |
private static java.util.Random |
random
|
protected boolean |
seatup
True iff the seat is up. |
Constructor Summary | |
Toilet()
|
Method Summary | |
void |
deposit(Waste w)
Place something in the toilet. |
void |
flush()
Make the contents of the toilet (if any) go away. |
boolean |
isYucky()
Does the toilet need flushing? |
static void |
main(java.lang.String[] args)
This isn't necessarily the real main program, but it will be run if we type "java Toilet", so it is a good way to test the Toilet class. |
void |
raiseSeat(boolean b)
Change the seat position. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Waste contents
protected boolean seatup
private static final float CLOG_PROBABILITY
private static java.util.Random random
Constructor Detail |
public Toilet()
Method Detail |
public void deposit(Waste w)
w
- The waste to deposit.public boolean isYucky()
true
if it does, false
otherwise.public void flush() throws FloatingOverflowException
FloatingOverflowException
- If the toilet happened to clog.
In this case it needs to be reflushed (after you clean up the
bathroom), although it might clog again.public void raiseSeat(boolean b)
b
- true to raise it, false to lower it.public static void main(java.lang.String[] args) throws FloatingOverflowException
FloatingOverflowException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |