/* * This class represents a position on the board. */ public class Position implements Comparable { /* Coordinates of the Position on the board */ public int x, y; /* Level of the position on the BFS wave */ public int l; /* * Constructor. */ public Position(int x, int y, int l) { this.x = x; this.y = y; this.l = l; } /* * Constructor */ public Position(Position p) { x = p.x; y = p.y; l = p.l; } /* Position objects are put in a TreeSet */ public int compareTo(Object o) { Position p = (Position)o; if (x < p.x) { return -1; } else if (x > p.x) { return 1; } else if (y < p.y) { return -1; } else if (y > p.y) { return 1; } return 0; } /* Position objects are put in a TreeSet */ public boolean equals(Object o) { Position p = (Position)o; return x == p.x && y == p.y; } }