From 3cf7005151eaf13981e85ea45b70bdf9b27aa5b0 Mon Sep 17 00:00:00 2001 From: Imbus Date: Mon, 11 Dec 2023 13:12:50 +0100 Subject: [PATCH] User feedback on unsolvable --- app/src/main/java/gui/SudokuController.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/gui/SudokuController.java b/app/src/main/java/gui/SudokuController.java index 348c997..69def49 100644 --- a/app/src/main/java/gui/SudokuController.java +++ b/app/src/main/java/gui/SudokuController.java @@ -25,10 +25,16 @@ public class SudokuController { @Override public void actionPerformed(ActionEvent e) { // Solve the board - model.solve(); + boolean solved = model.solve(); + if (!solved) { + view.showErrorMessage("Could not solve the board."); + System.out.println("Could not solve the board."); + System.out.println(model.toString()); + } else { + // Update the view + view.updateView(model.getBoard()); + } - // Update the view - view.updateView(model.getBoard()); } });