示例#1
0
 @Override
 public boolean equals(Object obj) {
   Intersection i = (Intersection) obj;
   if (i.getLocation().getX() == location.getX() && i.getLocation().getY() == location.getY()) {
     return true;
   }
   return false;
 }
 /**
  * Compare the user's result with the right answer.
  *
  * @param i The graph number
  * @param result The user's graph
  * @param corr The correct answer
  * @param start The point to start from
  * @param end The point to end at
  */
 public void judge(
     int i, MapGraph result, CorrectAnswer corr, GeographicPoint start, GeographicPoint end) {
   // Correct if paths are same length and have the same elements
   feedback +=
       appendFeedback(
           i,
           "Running Dijkstra's algorithm from ("
               + start.getX()
               + ", "
               + start.getY()
               + ") to ("
               + end.getX()
               + ", "
               + end.getY()
               + ")");
   List<GeographicPoint> path = result.dijkstra(start, end);
   if (path == null) {
     if (corr.path == null) {
       feedback += "PASSED.";
       correct++;
     } else {
       feedback +=
           "FAILED. Your implementation returned null; expected \n" + printPath(corr.path) + ".";
     }
   } else if (path.size() != corr.path.size() || !corr.path.containsAll(path)) {
     feedback += "FAILED. Expected: \n" + printPath(corr.path) + "Got: \n" + printPath(path);
     if (path.size() != corr.path.size()) {
       feedback += "Your result has size " + path.size() + "; expected " + corr.path.size() + ".";
     } else {
       feedback += "Correct size, but incorrect path.";
     }
   } else {
     feedback += "PASSED.";
     correct++;
   }
 }
示例#3
0
 public GeographicPoint getLocation() {
   return new GeographicPoint(location.getX(), location.getY());
 }