title: How to use Comparable to order a prioritylist of objects?
body: <p>Here is my object class. There are no errors here.</p>
  
  <pre><code>public class AStarNode implements Comparable&lt;AStarNode&gt; {
      AStarNode pathParent;
      int x;
      int y;
      int costFromStart;
      int estimatedCostToGoal;
  
      public int getCost() {
          return costFromStart + estimatedCostToGoal;
      }
  
      @Override
      public int compareTo(AStarNode node) {
          int otherValue = node.getCost();
          int thisValue = this.getCost();
          if(thisValue-otherValue &gt; 0) {
              return 1;
          }
          else {
              return 0;
          }
      }
  }
  </code></pre>
  
  <p>Here is something I have within my AStarSearch class. I'm getting errors here and I'm not sure what to do to fix them. I've been trying stuff for the past hour. What I'm trying to do is have a special method for PriorityList which adds the object somewhere into the PriorityList based on one of the objects variables. Can anyone point out where I'm going wrong?</p>
  
  <pre><code>public class PriorityList extends LinkedList {
      public void add(Comparable node) {
          for (int i=0; i&lt;size(); i++) {
              ￼￼￼if(node.compareTo(node) == 0) {
                  add(i, node);
                  return; 
              }
          }
          addLast(node);
      }
  }
  </code></pre>