2015-05-05 11:20:13 -07:00
|
|
|
|
//: patterns/doubledispatch/TypedBin.java
|
2015-05-29 14:18:51 -07:00
|
|
|
|
// <20>2015 MindView LLC: see Copyright.txt
|
2015-05-05 11:20:13 -07:00
|
|
|
|
// An ArrayList that can grab the right type.
|
|
|
|
|
package patterns.doubledispatch;
|
|
|
|
|
import patterns.trash.*;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
public abstract class TypedBin {
|
2015-05-06 15:14:33 -07:00
|
|
|
|
ArrayList<Trash> v = new ArrayList<>();
|
2015-05-05 11:20:13 -07:00
|
|
|
|
protected boolean addIt(Trash t) {
|
|
|
|
|
v.add(t);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-05-06 15:14:33 -07:00
|
|
|
|
public Iterator<Trash> elements() {
|
2015-05-05 11:20:13 -07:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
} ///:~
|