1  /**
  2     This class encapsulates a work order with a priority.
  3  */
  4  public class WorkOrder implements Comparable
  5  {
  6     private int priority;
  7     private String description;
  8  
  9     /**
 10        Constructs a work order with a given priority and description.
 11        @param aPriority the priority of this work order
 12        @param aDescription the description of this work order
 13     */
 14     public WorkOrder(int aPriority, String aDescription)
 15     {
 16        priority = aPriority;
 17        description = aDescription;
 18     }
 19  
 20     public String toString()
 21     {
 22        return "priority=" + priority + ", description=" + description;
 23     }
 24  
 25     public int compareTo(Object otherObject)
 26     {
 27        WorkOrder other = (WorkOrder) otherObject;
 28        if (priority < other.priority) { return -1; }
 29        if (priority > other.priority) { return 1; }
 30        return 0;
 31     }
 32  }