User feedback on unsolvable

This commit is contained in:
Imbus 2023-12-11 13:12:50 +01:00
parent 2acf69d466
commit 3cf7005151

View file

@ -25,11 +25,17 @@ public class SudokuController {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// Solve the board // 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 // Update the view
view.updateView(model.getBoard()); view.updateView(model.getBoard());
} }
}
}); });
view.addResetButtonListener(new ActionListener() { view.addResetButtonListener(new ActionListener() {