public abstract class Piece<T extends Piece> implements Comparable<T>{
//Note: This could also obviously return Piece
public abstract T collide(T other);
}
public class ChessPiece extends Piece<ChessPiece> {
public ChessPiece collide(ChessPiece other) {
return this;
}
public int compareTo(ChessPiece arg0) {
// TODO Auto-generated method stub
return 0;
}
}
public class RPGPiece extends Piece<RPGPiece>{
public int compareTo(RPGPiece o) {
// TODO Auto-generated method stub
return 0;
}
@Override
public RPGPiece collide(RPGPiece other) {
return this.compareTo(other) > 0 ? this: other;
}
}