Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // this is the springboot class
- @Controller
- public class SudokuController implements SudokuService {
- // instansvariabel av typen SudokuService och anvΓ€nd dig av @Autowired
- @Autowired
- SudokuService sudokuService;
- // new button GET
- @GetMapping ("/new")
- public void newBoard(){
- System.out.println("newButton ππ");
- }
- // reset button GET
- @GetMapping ("/reset")
- public void reset(){
- System.out.println("resetButton");
- }
- // i am calling the implement class and then .solve() to call the logic implemented in the other class!
- // solve button GET
- @GetMapping ("/solve")
- public void solve(){
- sudokuService.solve();
- System.out.println("solveButton");
- }
- //this is in another class
- // sudokuBoard
- @Override
- public boolean solve() {
- System.out.println("inside solve");
- for (int row = 0; row < board.length; row++)
- {
- for (int col = 0; col < board.length; col++)
- {
- if (board[row][col] == 0)
- {
- for (int n = 1; n <= 9; n++)
- {
- if (isLegal(n, row, col))
- {
- board[row][col] = n;
- if (solve())
- return true;
- else
- board[row][col] = 0;
- }
- }
- return false;
- }
- }
- }
- return true;
- }
- // this is in another class where im only allowed to use public void solve
- // so i call the previous class.solve()
- @Override
- public void solve() {
- sudokuBoard.solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement