/**
* 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:
*
* - We might want waste objects to have interesting data
* fields like w.volume, w.odor, and w.nitrogenContent.
*
- We might want waste objects to implement interesting methods
* like w.decompose(), and w.treat(Chemical).
*
- Specific subclasses of Waste might have
* additional fields, such as {@link SolidWaste}.count and {@link
* TrashWaste}.isBiodegradable.
*
- The Waste class might include static methods not associated
* with a particular object. For example, Waste.add(Waste,
* Waste) could combine two different waste objects.
* Waste.sum(Waste[]) could mix a whole array of different kinds
* of waste and return sewage sludge.
*
*
* @author Jason Eisner
* @version 1.0, 2003-01-26
*/
public class Waste {
protected String description;
/** The constructor; we could add others.
* @param s A description of the waste.
*/
public Waste(String s) { // constructor (could have others)
description = s;
}
/** To get a printable version of the waste, we just
* use its description string. This overrides the default
* toString() method inherited from Object.
*/
public String toString() {
return description;
}
/** 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)
.
*
* @param t The destination.
*/
public void deposit(Toilet t) {
t.deposit(this);
}
}