Ejemplo n.º 1
0
 private Board getSudokoBoardById(Integer id) {
   Board sudokoBoard = sudokoBoardRepository.getBoard(id);
   if (!sudokoBoard.getChached()) {
     return null;
   }
   return sudokoBoard;
 }
Ejemplo n.º 2
0
  @Override
  public BasicSudokoDTO createSudokoBoard(BasicSudokoDTO sudoko) {

    Board sudokoBoard = sudokoBoardRepository.getBoard(sequencer.next());
    sudokoBoard.create(sudoko.getSudokoBoardAsString());
    boolean isValidBoard = solver.isValid(sudokoBoard.getSolutionArray());
    if (isValidBoard) {
      Boolean solutionExist = solver.solve(sudokoBoard.getSolutionArray());
      if (solutionExist) {
        sudokoBoard.setHavingSolution(solutionExist);
        sudoko.setIsValidBoard(isValidBoard);
        sudokoBoard.setChached(Boolean.TRUE);
        sudoko.setId(sudokoBoard.getId());
      }
    }
    if (!sudoko.getIsValidBoard()) {
      throw new NotValidBoardException(sudoko.getSudokoBoardAsString());
    }

    return sudoko;
  }