2015-11-03 12:00:44 -08:00

26 lines
527 B
Java

// patterns/doubledispatch/TypedBin.java
// A List that can grab the right type.
package patterns.doubledispatch;
import patterns.trash.*;
import java.util.*;
public abstract class TypedBin {
List<Trash> v = new ArrayList<>();
protected boolean addIt(Trash t) {
v.add(t);
return true;
}
public boolean add(Aluminum a) {
return false;
}
public boolean add(Paper a) {
return false;
}
public boolean add(Glass a) {
return false;
}
public boolean add(Cardboard a) {
return false;
}
}