//: c17:doubledispatch:TypedBin.java // From Thinking in Java, 2nd Edition // Available at http://www.BruceEckel.com // (c) Bruce Eckel 1999 // Copyright notice in Copyright.txt // ArrayList that knows how to grab the right type package c17.doubledispatch; import c17.trash.*; import java.util.*; public abstract class TypedBin { ArrayList v = new ArrayList(); protected boolean addIt(Trash t) { v.add(t); return true; } public Iterator elements() { return v.iterator(); } public boolean add(DDAluminum a) { return false; } public boolean add(DDPaper a) { return false; } public boolean add(DDGlass a) { return false; } public boolean add(DDCardboard a) { return false; } } ///:~