Class Waste

java.lang.Object
  |
  +--Waste
Direct Known Subclasses:
LiquidWaste, SolidWaste, TrashWaste

public class Waste
extends java.lang.Object

Stuff that you might try to flush down a toilet.

We'll distinguish among a few different varieties of waste by having different subclasses. But none of the Waste classes currently have any interesting fields or methods, since the toilet doesn't need to do anything interesting with the waste, just erase it.

If we decided our program should follow the waste through the sewage system and process it, then we could add details to the class:


Field Summary
protected  java.lang.String description
           
 
Constructor Summary
Waste(java.lang.String s)
          The constructor; we could add others.
 
Method Summary
 void deposit(Toilet t)
          This is a convenience function.
 java.lang.String toString()
          To get a printable version of the waste, we just use its description string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

description

protected java.lang.String description
Constructor Detail

Waste

public Waste(java.lang.String s)
The constructor; we could add others.

Parameters:
s - A description of the waste.
Method Detail

toString

public java.lang.String toString()
To get a printable version of the waste, we just use its description string. This overrides the default toString() method inherited from Object.

Overrides:
toString in class java.lang.Object

deposit

public void deposit(Toilet t)
This is a convenience function. If w is some waste and t is a toilet, then w.deposit(t) is the same as t.deposit(w).

Parameters:
t - The destination.