|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.act365.sudoku.MaskFactory
The MaskFactory class iterates through the complete set of possible masks (a mask is a boolean[][] array that indicates whether the corresponding cells in Su Doku grids should have their initial values exposed) of a given size. The masks are guaranteed to have rotational symmetry of order two, as demanded by the Su Doku puzzle. No mask will be a reflection of a mask that appeared earlier in the sequence.
| Constructor Summary | |
MaskFactory(int cellsInRow,
int filledCells)
Creates a new MaskFactory. |
|
MaskFactory(int cellsInRow,
int filledCells,
boolean randomize)
Creates a new MaskFactory. |
|
MaskFactory(int cellsInRow,
int filledCells,
boolean[][] mask)
Creates a new MaskFactory. |
|
MaskFactory(int cellsInRow,
int filledCells,
int boxesAcross)
Creates a new MaskFactory. |
|
MaskFactory(int cellsInRow,
int filledCells,
int[] gaps)
Creates a new MaskFactory. |
|
MaskFactory(java.lang.String s)
Creates a new MaskFactory. |
|
| Method Summary | |
int |
getCellsInRow()
Returns the mask dimension. |
int |
getFilledCells()
Returns the number of filled cells in the mask. |
boolean |
hasMoreElements()
Indicates whether the MaskFactory has cycled through the complete set of all possible masks. |
static boolean |
isSymmetricLeftRight(boolean[][] mask)
Determines whether the mask is symmetric in a line that extends from the left centre of the grid to the right centre. |
static boolean |
isSymmetricOrder2(boolean[][] mask)
Determines whether a mask has rotational symmetry of order 2. |
static boolean |
isSymmetricOrder4(boolean[][] mask)
Determines whether a mask has rotational symmetry of order 4. |
static boolean |
isSymmetricTopBottom(boolean[][] mask)
Determines whether the mask is symmetric in a line that extends from the top centre of the grid to the bottom centre. |
static boolean |
isSymmetricTopLeftBottomRight(boolean[][] mask)
Determines whether the mask is symmetric in a line that extends from the top-left corner of the grid to the bottom-right. |
static boolean |
isSymmetricTopRightBottomLeft(boolean[][] mask)
Determines whether the mask is symmetric in a line that extends from the top-right corner of the grid to the bottom-left. |
static void |
main(java.lang.String[] args)
Class test program takes the form MaskFactory [-c cellsInRow] [-r|-i|-a boxes across] [-d] filledCells. |
java.lang.Object |
nextElement()
Returns the next mask. |
java.lang.String |
toString()
Writes the mask as a string. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public MaskFactory(int cellsInRow,
int filledCells)
throws java.lang.Exception
cellsInRow - size of gridfilledCells - number of true elements to appear in mask
java.lang.Exception - thrown if cellsInRow and filledCells are incompatible
public MaskFactory(int cellsInRow,
int filledCells,
boolean randomize)
throws java.lang.Exception
cellsInRow - size of gridfilledCells - number of true elements to appear in maskrandomize - whether the start position should be randomized
java.lang.Exception - thrown if cellsInRow and filledCells are incompatible
public MaskFactory(int cellsInRow,
int filledCells,
boolean[][] mask)
throws java.lang.Exception
cellsInRow - size of gridfilledCells - number of true elements to appear in maskmask - start mask
java.lang.Exception - thrown if cellsInRow and filledCells are incompatible
public MaskFactory(int cellsInRow,
int filledCells,
int[] gaps)
throws java.lang.Exception
cellsInRow - size of gridfilledCells - number of true elements to appear in maskgaps - gap sequence that defines the start mask
java.lang.Exception - thrown if cellsInRow and filledCells are incompatible
public MaskFactory(java.lang.String s)
throws java.lang.Exception
toString().
s - string representation of start mask
java.lang.Exception - thrown if cellsInRow and filledCells are incompatible
public MaskFactory(int cellsInRow,
int filledCells,
int boxesAcross)
throws java.lang.Exception
cellsInRow - size of gridfilledCells - number of true elements to appear in maskboxesAcross - grid dimension
java.lang.Exception - thrown if cellsInRow and filledCells are incompatible| Method Detail |
public java.lang.String toString()
public boolean hasMoreElements()
hasMoreElements in interface java.util.Enumerationpublic java.lang.Object nextElement()
nextElement in interface java.util.Enumerationpublic int getCellsInRow()
public int getFilledCells()
public static boolean isSymmetricLeftRight(boolean[][] mask)
public static boolean isSymmetricTopBottom(boolean[][] mask)
public static boolean isSymmetricTopLeftBottomRight(boolean[][] mask)
public static boolean isSymmetricTopRightBottomLeft(boolean[][] mask)
public static boolean isSymmetricOrder2(boolean[][] mask)
public static boolean isSymmetricOrder4(boolean[][] mask)
public static void main(java.lang.String[] args)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||