// file: Square.java // author: Robert Keller // purpose: One suare of a Grid /** * a single Square of the grid */ class Square { /** * the contents of the Square */ int contents; /** * coordinates of the parent of the Square, during searching */ Pair parent; /** * Construct a square from specified contents. * @param the contents */ Square(int contents) { this.contents = contents; parent = null; } /** * Return the contents of the Square. */ int get() { return contents; } /** * Set the contents of the Square. */ void set(int contents) { this.contents = contents; } /** * See if the Square contains specified contents. */ boolean contains(int value) { return contents == value; } /** * Set the parent of this Square */ void setParent(Pair parent) { this.parent = parent; } /** * Set if this Square has been visited. */ boolean isMarked() { return parent != null; } }