Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1. // this is the springboot class
  2. @Controller
  3. public class SudokuController implements SudokuService {
  4.    
  5.     // instansvariabel av typen SudokuService och anvΓ€nd dig av @Autowired
  6.     @Autowired
  7.     SudokuService sudokuService;
  8.    
  9.     // new button GET
  10.     @GetMapping ("/new")
  11.     public void newBoard(){
  12.         System.out.println("newButton 😍😍");
  13.     }
  14.    
  15.     // reset button GET
  16.     @GetMapping ("/reset")
  17.     public void reset(){
  18.         System.out.println("resetButton");
  19.     }
  20.    
  21.     // i am calling the implement class and then .solve() to call the logic implemented in the other class!
  22.     // solve button GET
  23.     @GetMapping ("/solve")
  24.     public void solve(){
  25.         sudokuService.solve();
  26.         System.out.println("solveButton");
  27.     }
  28.  
  29.     //this is in another class
  30.     // sudokuBoard
  31.     @Override
  32.     public boolean solve() {
  33.         System.out.println("inside solve");
  34.         for (int row = 0; row < board.length; row++)
  35.         {
  36.             for (int col = 0; col < board.length; col++)
  37.             {
  38.                 if (board[row][col] == 0)
  39.                 {
  40.                     for (int n = 1; n <= 9; n++)
  41.                     {
  42.                         if (isLegal(n, row, col))
  43.                         {
  44.                             board[row][col] = n;
  45.                             if (solve())
  46.                                 return true;
  47.                             else
  48.                                 board[row][col] = 0;
  49.                         }
  50.                     }
  51.                     return false;
  52.                 }
  53.             }
  54.         }
  55.         return true;
  56.     }
  57.    
  58.  
  59.     // this is in another class where im only allowed to use public void solve
  60.     // so i call the previous class.solve()
  61.     @Override
  62.     public void solve() {
  63.         sudokuBoard.solve();
  64.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement