update ConsoleInterface
All checks were successful
Linux arm64 / Build (push) Successful in 42s

This commit is contained in:
Janet-Doe
2025-02-02 21:31:32 +01:00
parent c481f66b0c
commit 591e4f977a
2 changed files with 13 additions and 7 deletions

View File

@@ -21,12 +21,16 @@ public class ConsoleInterface {
public void welcome() {
System.out.println("Welcome to our Sudoku Solver!");
System.out.println("This is the project of Melvyn Bauvent, Lilas Grenier and Simon Pribylski.");
createDoku();
/*
System.out.println("Do you have a save sudoku you would like to continue? (y/n, default n)");
if (reader.next().equalsIgnoreCase("y")) {
useSavedDoku();
} else {
createDoku();
}
*/
}
/**
@@ -94,6 +98,7 @@ public class ConsoleInterface {
if (difficulty.equals("full")) {
generateFullDoku(doku);
System.out.println("Here's your sudoku !");
showMultidoku(doku, listSymbols, width, height);
exit();
} else {
generatePartialDoku(doku, difficulty);
@@ -141,10 +146,13 @@ public class ConsoleInterface {
MultiDoku md = null;
do {
nbSave = reader.nextInt();
if (nbSave == -1) {
System.exit(0);
}
try {
md = SudokuSerializer.getSavedMultiDoku(nbSave);
} catch (Exception e) {
System.out.println("There seems to be a problem with this save, please try again.");
System.out.println("There seems to be a problem with this save, please try again or write '-1' to abort.");
}
} while (md == null);
return md;
@@ -348,7 +356,7 @@ public class ConsoleInterface {
* @param width int, largeur d'un bloc du sudoku
* @param height int, hauteur d'un bloc du sudoku
* @param step SolverStep, étape de résolution à afficher
* @return
* @return boolean, valant true si l'utilisateur veut afficher l'étape, false sinon
*/
private boolean showStep(MultiDoku doku, List<String> listSymbols, int width, int height, SolverStep step) {
System.out.println("Here is the step : \n");
@@ -401,6 +409,7 @@ public class ConsoleInterface {
new RandomSolver().solve(doku, steps);
break;
}
showMultidoku(doku, listSymbols, width, height);
showSolveSteps(doku, listSymbols, width, height, steps);
}
@@ -444,10 +453,7 @@ public class ConsoleInterface {
*/
private boolean isValidCoordinates(RenderableMultidoku doku, int width, int height, int x, int y) {
Cell cell = doku.getCell(x, y);
if ((cell != null) && cell.isMutable()) {
return true;
}
return false;
return ((cell != null) && cell.isMutable());
}
/**

View File

@@ -173,7 +173,7 @@ public class SudokuSerializer {
* Get a MultiDoku from a pre-existing json save file.
*
* @param numberSave int, number of the save file to open.
* @return MultiDoku, MultoDoku contained in the file.
* @return MultiDoku, MultiDoku contained in the file.
* @throws Exception when the given save file does not exist.
*/
public static MultiDoku getSavedMultiDoku(int numberSave) throws Exception {