FileDocCategorySizeDatePackage
RecycleA.javaAPI DocExample4936Mon Apr 06 18:10:26 BST 1998c16.recyclea

Trash

public abstract class Trash extends Object

Fields Summary
private double
weight
Constructors Summary
Trash(double wt)

 weight = wt; 
Methods Summary
static voidsumValue(java.util.Vector bin)

    Enumeration e = bin.elements();
    double val = 0.0f;
    while(e.hasMoreElements()) {
      // One kind of RTTI:
      // A dynamically-checked cast
      Trash t = (Trash)e.nextElement();
      // Polymorphism in action:
      val += t.weight() * t.value();
      System.out.println(
        "weight of " +
        // Using RTTI to get type
        // information about the class:
        t.getClass().getName() +
        " = " + t.weight());
    }
    System.out.println("Total value = " + val);
  
abstract doublevalue()

doubleweight()

 return weight;