Java Reference
In-Depth Information
if (sizeof puzzle != sizeof spaces) {
throw new Exception(
"SudokuGenerator puzzle incompatible");
}
/*
* Populate our spaces with the Integer sequence
* returned by the
* sudokuGrid.returnGridSequence() glue.
*/
clearPuzzle();
for (i in [0..<sizeof puzzle]) {
if ((spaces[i].row !=
sudokuGrid.getX(puzzle[i])) or
(spaces[i].column !=
sudokuGrid.getY(puzzle[i]))) {
throw new Exception(
"Bad data returned by SudokuGenerator");
}
spaces[i].setSolvedNumber(
sudokuGrid.getGridVal(puzzle[i]));
if (sudokuGrid.isDefault(puzzle[i])) {
spaces[i].setNumberUnEditable(
sudokuGrid.getGridVal(puzzle[i]));
}
else {
spaces[i].setNumberEditable(0);
}
}
}
Chapter Summary
We've spent some time dissecting our sample Sudoku application including
describing the user interface, the organization of the source, the overall architec-
ture, and the interaction with components written elsewhere in Java. Feel free to
take a look at the source and utilize it in any fashion you wish.
 
Search WWH ::




Custom Search