Create Xref-Html Frames                    Remove All Frames
file:/home/jason/teach/226/jason/toilet/Waste.java        (Sun Jan 26 22:15:47 2003 )


   1: /**
   2:  * Stuff that you might try to flush down a toilet.<p>
   3:  * 
   4:  * We'll distinguish among a few different varieties of waste by
   5:  * having different subclasses.  But none of the Waste classes
   6:  * currently have any interesting fields or methods, since the toilet
   7:  * doesn't need to do anything interesting with the waste, just erase
   8:  * it.<p>
   9:  *
  10:  * If we decided our program should follow the waste through the
  11:  * sewage system and process it, then we could add details to the
  12:  * class:
  13:  * <UL>
  14:  * <LI> We might want waste objects to have interesting data
  15:  *      fields like w.volume, w.odor, and w.nitrogenContent.
  16:  * <LI> We might want waste objects to implement interesting methods 
  17:  *      like w.decompose(), and w.treat(Chemical).  
  18:  * <LI> Specific subclasses of Waste might have
  19:  *      additional fields, such as {@link SolidWaste}.count and {@link
  20:  *      TrashWaste}.isBiodegradable.
  21:  * <LI> The Waste class might include static methods not associated
  22:  *      with a particular object.  For example, Waste.add(Waste,
  23:  *      Waste) could combine two different waste objects.
  24:  *      Waste.sum(Waste[]) could mix a whole array of different kinds
  25:  *      of waste and return sewage sludge.
  26:  * </UL>
  27:  *
  28:  * @author Jason Eisner
  29:  * @version 1.0, 2003-01-26
  30:  */
  31: 
  32: 
  33: public class Waste {
  34:   protected String description;
  35: 
  36:   /** The constructor; we could add others.
  37:    * @param s A description of the waste.
  38:    */
  39:   public Waste(String s) {    // constructor (could have others)
  40:     description = s;
  41:   }
  42: 
  43:   /** To get a printable version of the waste, we just
  44:    * use its description string.  This overrides the default
  45:    * toString() method inherited from Object. 
  46:    */
  47:   public String toString() {  
  48:     return description;
  49:   }
  50: 
  51:   /** This is a convenience function.  If <code>w</code> is some
  52:    * waste and <code>t</code> is a toilet, then
  53:    * <code>w.deposit(t)</code> is the same as <code>t.deposit(w)</code>.
  54:    *
  55:    * @param t The destination.
  56:    */
  57:   public void deposit(Toilet t) {  
  58:     t.deposit(this);   
  59:   }
  60: }
  61: 
  62: 








































Html form generated by Xref-Java2Html version 1.4.0 on Mon Jan 27 13:59:15 2003