diff --git a/app/src/main/java/gui/SudokuController.java b/app/src/main/java/gui/SudokuController.java index a283ab8..0d91eed 100644 --- a/app/src/main/java/gui/SudokuController.java +++ b/app/src/main/java/gui/SudokuController.java @@ -127,6 +127,15 @@ public class SudokuController { // Update the model and view model.set(row, col, value); + + // Warn if the board is not solvable (e.g. if the user has made a mistake) + // This is very messy, error prone and computationally expensive + if(!model.isSolvable()) { + model.set(row, col, 0); + view.showErrorMessage("Illegal move. The board is not solvable."); + } + + // Sync the view with the model view.updateView(model.getBoard()); } }