/** * Default constructor that allows to initialize sudoku from form.<br/> * NOTE : It also initialize authorized values for empty cell.<br/> * @param SudokuForm $sudokuForm Sudoku form containing values to use to initialize sudoku grid. */ public function __construct(SudokuForm $sudokuForm) { $this->blockSize = $sudokuForm->getBlockSize(); $this->fullSize = $this->blockSize * $this->blockSize; $this->sudokuGrid = array(); // Browse all cells and initialize them for ($i = 0; $i < $this->fullSize; $i++) { for ($j = 0; $j < $this->fullSize; $j++) { $this->sudokuGrid[$i][$j] = new SudokuCell($i, $j, $sudokuForm->getValue($i, $j), $sudokuForm->getStatus($i, $j), $this->blockSize); } } }
public function debugFiller(SudokuForm $form) { $form->initCell(0, 0, 5, SudokuStatus::INITIAL); $form->initCell(0, 1, 2, SudokuStatus::INITIAL); $form->initCell(0, 2, 8, SudokuStatus::INITIAL); $form->initCell(0, 8, 4, SudokuStatus::INITIAL); $form->initCell(1, 0, 6, SudokuStatus::INITIAL); $form->initCell(1, 1, 3, SudokuStatus::INITIAL); $form->initCell(1, 2, 1, SudokuStatus::INITIAL); $form->initCell(1, 3, 4, SudokuStatus::INITIAL); $form->initCell(1, 5, 8, SudokuStatus::INITIAL); $form->initCell(2, 0, 7, SudokuStatus::INITIAL); $form->initCell(2, 1, 9, SudokuStatus::INITIAL); $form->initCell(2, 2, 4, SudokuStatus::INITIAL); $form->initCell(2, 3, 2, SudokuStatus::INITIAL); $form->initCell(2, 5, 6, SudokuStatus::INITIAL); $form->initCell(2, 7, 3, SudokuStatus::INITIAL); $form->initCell(2, 8, 8, SudokuStatus::INITIAL); $form->initCell(3, 0, 8, SudokuStatus::INITIAL); $form->initCell(3, 1, 6, SudokuStatus::INITIAL); $form->initCell(3, 2, 7, SudokuStatus::INITIAL); $form->initCell(3, 8, 1, SudokuStatus::INITIAL); $form->initCell(4, 0, 2, SudokuStatus::INITIAL); $form->initCell(4, 1, 5, SudokuStatus::INITIAL); $form->initCell(4, 2, 3, SudokuStatus::INITIAL); $form->initCell(4, 3, 1, SudokuStatus::INITIAL); $form->initCell(5, 0, 4, SudokuStatus::INITIAL); $form->initCell(5, 1, 1, SudokuStatus::INITIAL); $form->initCell(5, 2, 9, SudokuStatus::INITIAL); $form->initCell(5, 4, 6, SudokuStatus::INITIAL); $form->initCell(5, 6, 2, SudokuStatus::INITIAL); $form->initCell(5, 8, 3, SudokuStatus::INITIAL); $form->initCell(6, 0, 9, SudokuStatus::INITIAL); $form->initCell(6, 1, 7, SudokuStatus::INITIAL); $form->initCell(6, 2, 6, SudokuStatus::INITIAL); $form->initCell(6, 3, 8, SudokuStatus::INITIAL); $form->initCell(6, 6, 3, SudokuStatus::INITIAL); $form->initCell(6, 7, 4, SudokuStatus::INITIAL); $form->initCell(6, 8, 2, SudokuStatus::INITIAL); $form->initCell(7, 0, 1, SudokuStatus::INITIAL); $form->initCell(7, 1, 4, SudokuStatus::INITIAL); $form->initCell(7, 2, 2, SudokuStatus::INITIAL); $form->initCell(7, 6, 8, SudokuStatus::INITIAL); $form->initCell(8, 0, 3, SudokuStatus::INITIAL); $form->initCell(8, 1, 8, SudokuStatus::INITIAL); $form->initCell(8, 2, 5, SudokuStatus::INITIAL); $form->initCell(8, 3, 9, SudokuStatus::INITIAL); $form->initCell(8, 4, 4, SudokuStatus::INITIAL); $form->initCell(8, 5, 2, SudokuStatus::INITIAL); $form->initCell(8, 6, 6, SudokuStatus::INITIAL); $form->initCell(8, 7, 1, SudokuStatus::INITIAL); $form->initCell(8, 8, 7, SudokuStatus::INITIAL); }