com.act365.sudoku
Class Grid

java.lang.Object
  extended bycom.act365.sudoku.Grid
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class Grid
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

A Grid object represents a partially-filled Su Doku grid.

See Also:
Serialized Form

Constructor Summary
Grid()
          Creates a dimensionless Su Doku grid.
Grid(int boxesAcross, int boxesDown)
          Creates a Su Doku grid with the given number of boxes (aka subgrids) in each dimension.
 
Method Summary
 java.lang.Object clone()
          Clones the grid.
 int countFilledCells()
          Counts the number of filled cells in the grid.
 boolean equals(java.lang.Object obj)
          Tests for equality.
 Grid populate(java.lang.String s)
          Populates the grid from a string.
 Grid rectify(boolean[][] mask)
          Reflects, rotates and rearranges the grid as necessary in order to reduce it to its lowest form.
 void reset()
          Resets the value of each grid square.
 void resize(int boxesAcross, int boxesDown)
          Sets the number of boxes in the Su Doku grid.
 Grid shuffle()
          Randomly shuffles the current grid.
 int solve(IStrategy strategy, int maxSolns)
          Solves the grid.
 java.lang.String toString()
          Produces a string representation of the grid.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Grid

public Grid(int boxesAcross,
            int boxesDown)
Creates a Su Doku grid with the given number of boxes (aka subgrids) in each dimension.


Grid

public Grid()
Creates a dimensionless Su Doku grid. The grid will have to be redimensioned before it stores a puzzle.

Method Detail

clone

public java.lang.Object clone()
Clones the grid.


resize

public void resize(int boxesAcross,
                   int boxesDown)
Sets the number of boxes in the Su Doku grid.


populate

public Grid populate(java.lang.String s)
Populates the grid from a string.

Parameters:
s - string in the format created by toString()

countFilledCells

public int countFilledCells()
Counts the number of filled cells in the grid.


solve

public int solve(IStrategy strategy,
                 int maxSolns)
Solves the grid.

Parameters:
strategy - strategy to be used
maxSolns - the maximum number of solutions to be sought
Returns:
number of solutions found

reset

public void reset()
Resets the value of each grid square.


toString

public java.lang.String toString()
Produces a string representation of the grid.


equals

public boolean equals(java.lang.Object obj)
Tests for equality.


rectify

public Grid rectify(boolean[][] mask)
Reflects, rotates and rearranges the grid as necessary in order to reduce it to its lowest form.


shuffle

public Grid shuffle()
Randomly shuffles the current grid.