UNB/ CS/ David Bremner/ teaching/ java/ Link.java
/**
   The Link class of objects.
   @author  Steve Rauch
   modified by David Bremner
*/
class Link implements Comparable {
  private Comparable data;
  private Link next;
  public Link(Comparable comp){
    data=comp;
    next=null;
  }

  public Link getNext(){
    return next;
  }

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

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

    return getData().compareTo( ((Link)other).getData());
  }
}