codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
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; } }
Private
[
?
]
Run code
Submit