Class AutoToilet

java.lang.Object
  |
  +--Toilet
        |
        +--AutoToilet

public class AutoToilet
extends Toilet

A better Toilet. It automatically cleans up after itself if it overflows, so it never throws an exception. It also tries to raise and lower the seat for you, although this turned out to be a bad idea.


Field Summary
 
Fields inherited from class Toilet
contents, seatup
 
Constructor Summary
AutoToilet()
           
 
Method Summary
 void deposit(LiquidWaste lw)
          Although we inherit the general Toilet.deposit(Waste) method from our parent class, we also override it with this more specific method for liquid waste.
 void flush()
          Like Toilet.flush(), but cleans up instead of throwing an exception.
static void main(java.lang.String[] args)
          Test function similar to Toilet.main(java.lang.String[]).
 void raiseSeat(boolean b)
          Since this kind of toilet has an automatic seat raiser, the user can't move the seat.
protected  void raiseSeatAuto(boolean b)
          Internally, the class's implementation will call this protected method to move the seat.
 
Methods inherited from class Toilet
deposit, isYucky
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoToilet

public AutoToilet()
Method Detail

flush

public void flush()
Like Toilet.flush(), but cleans up instead of throwing an exception.

Overrides:
flush in class Toilet

deposit

public void deposit(LiquidWaste lw)
Although we inherit the general Toilet.deposit(Waste) method from our parent class, we also override it with this more specific method for liquid waste. The method automatically raises and lowers the seat for you when you pee. Alas, tests show dissatisfaction among female users.

Parameters:
lw - The liquid waste

raiseSeat

public void raiseSeat(boolean b)
Since this kind of toilet has an automatic seat raiser, the user can't move the seat. So we override the inherited raiseSeat method with one that has no effect. (We do print a warning message; alternatively, we could throw an exception.)

Really we shouldn't even be able to call raiseSeat at all on an AutoToilet. Unfortunately, by defining a raiseSeat method for Toilet, we have told the compiler that it's legal to call raiseSeat on any Toilet object, including subclasses. So we'd have to change that -- i.e., only some subclasses of Toilet should support this method.

Overrides:
raiseSeat in class Toilet
Parameters:
b - true to raise it, false to lower it.

raiseSeatAuto

protected void raiseSeatAuto(boolean b)
Internally, the class's implementation will call this protected method to move the seat. The user can't call this.


main

public static void main(java.lang.String[] args)
Test function similar to Toilet.main(java.lang.String[]).