Guest User

Node for pathfinding

a guest
Jan 20th, 2014
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. public class Node {
  2.  
  3.     private Node parent;
  4.     private final int passability;// проходимость
  5.     private final int x, y;
  6.  
  7.     Node(Node parent, int x, int y, int p) {
  8.         this.parent = parent;
  9.         passability = p;
  10.         this.x = x;
  11.         this.y = y;
  12.     }
  13.  
  14.     void setParent(Node n) {
  15.         parent = n;
  16.     }
  17.  
  18.     Node getParent() {
  19.         return parent;
  20.     }
  21.  
  22.     int getPassability() {
  23.         return passability;
  24.     }
  25.  
  26.     public int getX() {
  27.         return x;
  28.     }
  29.  
  30.     public int getY() {
  31.         return y;
  32.     }
  33.  
  34.     @Override
  35.     public String toString() {
  36.         return "node: " + x + ", " + y;
  37.     }
  38.  
  39.     @Override
  40.     public boolean equals(Object o) {
  41.         if (o != null && o instanceof Node) {
  42.             Node n = (Node) o;
  43.             return getX() == n.getX() && getY() == n.getY();
  44.         } else {
  45.             return false;
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment