UNB/ CS/ David Bremner/ teaching/ java/ GComparableNode.java
class GComparableNode implements Comparable<GComparableNode> {
    private Comparable data;
    private ComparableNode next;
    public ComparableNode(Comparable comp){
        data=comp;
        next=null;
    }
    public ComparableNode getNext(){
        return next;
    }

    public void setNext(ComparableNode val){
        next=val;
    }

    public Comparable getData(){
        return data;
    }
    public int compareTo(Object other){
        if (! (other instanceof ComparableNode) )
            throw new ClassCastException("ComparableNodes can only be" +
                                         "compared to ComparableNodes");

        return getData().compareTo(
               ((ComparableNode)other).getData());
  }
}
//