Guest User

Untitled

a guest
Oct 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. package com.citizens.Pathfinding;
  2.  
  3. public class PathNode implements Comparable<PathNode> {
  4. public Point point;
  5. public final PathNode parent;
  6. public int cost;
  7. public int totalCost;
  8.  
  9. public PathNode(Point point, PathNode parent, short cost, short totalCost) {
  10. this.point = point;
  11. this.parent = parent;
  12. this.cost = cost;
  13. this.totalCost = totalCost;
  14. }
  15.  
  16. public PathNode() {
  17. this.point = null;
  18. this.parent = null;
  19. this.cost = this.totalCost = 0;
  20. }
  21.  
  22. public PathNode(PathNode path) {
  23. this.parent = path;
  24. this.cost = path.cost;
  25. this.totalCost = path.totalCost;
  26. }
  27.  
  28. @Override
  29. public int compareTo(PathNode node) {
  30. int result = node.totalCost - node.cost;
  31. if (result > node.totalCost)
  32. return 1;
  33. else if (result == 0)
  34. return 0;
  35. else
  36. return -1;
  37. }
  38. }
Add Comment
Please, Sign In to add comment