Skip to content

Commit 19f4c3a

Browse files
committed
Three
1 parent 3d79aee commit 19f4c3a

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

Controller.java

+17-5
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,24 @@ private void setupSolveButton(){
1919
button.addActionListener(e -> {
2020
Solver solver;
2121
try {
22-
solver = new Solver(getInputClues(blocks));
23-
solver.solveGrid();
24-
Cell[][] grid = solver.getGrid();
25-
philGridd(grid, blocks);
22+
Cell[] clues = getInputClues(blocks);
23+
int pretty = 0;
24+
for(Cell clue:clues){
25+
if(clue.getValue().equals(3)){
26+
pretty++;
27+
}
28+
}
29+
if(pretty==81){
30+
JOptionPane.showMessageDialog(window, "Beautiful!", "333333", JOptionPane.INFORMATION_MESSAGE);
31+
}else {
32+
solver = new Solver(clues);
33+
solver.solveGrid();
34+
Cell[][] grid = solver.getGrid();
35+
philGridd(grid, blocks);
36+
}
2637
}catch (Exception uDoneGoofedMate){
27-
JOptionPane.showMessageDialog(window, "Invalid Sudoku!");
38+
JOptionPane.showMessageDialog(window, "That arrangement of clues isn't possible to solve!", "Invalid Sudoku", JOptionPane.ERROR_MESSAGE);
39+
2840
revertFormat();
2941
}
3042
});

0 commit comments

Comments
 (0)