This commit is contained in:
@@ -21,12 +21,16 @@ public class ConsoleInterface {
|
|||||||
public void welcome() {
|
public void welcome() {
|
||||||
System.out.println("Welcome to our Sudoku Solver!");
|
System.out.println("Welcome to our Sudoku Solver!");
|
||||||
System.out.println("This is the project of Melvyn Bauvent, Lilas Grenier and Simon Pribylski.");
|
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)");
|
System.out.println("Do you have a save sudoku you would like to continue? (y/n, default n)");
|
||||||
if (reader.next().equalsIgnoreCase("y")) {
|
if (reader.next().equalsIgnoreCase("y")) {
|
||||||
useSavedDoku();
|
useSavedDoku();
|
||||||
} else {
|
} else {
|
||||||
createDoku();
|
createDoku();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,6 +98,7 @@ public class ConsoleInterface {
|
|||||||
if (difficulty.equals("full")) {
|
if (difficulty.equals("full")) {
|
||||||
generateFullDoku(doku);
|
generateFullDoku(doku);
|
||||||
System.out.println("Here's your sudoku !");
|
System.out.println("Here's your sudoku !");
|
||||||
|
showMultidoku(doku, listSymbols, width, height);
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
generatePartialDoku(doku, difficulty);
|
generatePartialDoku(doku, difficulty);
|
||||||
@@ -141,10 +146,13 @@ public class ConsoleInterface {
|
|||||||
MultiDoku md = null;
|
MultiDoku md = null;
|
||||||
do {
|
do {
|
||||||
nbSave = reader.nextInt();
|
nbSave = reader.nextInt();
|
||||||
|
if (nbSave == -1) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
md = SudokuSerializer.getSavedMultiDoku(nbSave);
|
md = SudokuSerializer.getSavedMultiDoku(nbSave);
|
||||||
} catch (Exception e) {
|
} 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);
|
} while (md == null);
|
||||||
return md;
|
return md;
|
||||||
@@ -348,7 +356,7 @@ public class ConsoleInterface {
|
|||||||
* @param width int, largeur d'un bloc du sudoku
|
* @param width int, largeur d'un bloc du sudoku
|
||||||
* @param height int, hauteur d'un bloc du sudoku
|
* @param height int, hauteur d'un bloc du sudoku
|
||||||
* @param step SolverStep, étape de résolution à afficher
|
* @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) {
|
private boolean showStep(MultiDoku doku, List<String> listSymbols, int width, int height, SolverStep step) {
|
||||||
System.out.println("Here is the step : \n");
|
System.out.println("Here is the step : \n");
|
||||||
@@ -401,6 +409,7 @@ public class ConsoleInterface {
|
|||||||
new RandomSolver().solve(doku, steps);
|
new RandomSolver().solve(doku, steps);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
showMultidoku(doku, listSymbols, width, height);
|
||||||
showSolveSteps(doku, listSymbols, width, height, steps);
|
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) {
|
private boolean isValidCoordinates(RenderableMultidoku doku, int width, int height, int x, int y) {
|
||||||
Cell cell = doku.getCell(x, y);
|
Cell cell = doku.getCell(x, y);
|
||||||
if ((cell != null) && cell.isMutable()) {
|
return ((cell != null) && cell.isMutable());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ public class SudokuSerializer {
|
|||||||
* Get a MultiDoku from a pre-existing json save file.
|
* Get a MultiDoku from a pre-existing json save file.
|
||||||
*
|
*
|
||||||
* @param numberSave int, number of the save file to open.
|
* @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.
|
* @throws Exception when the given save file does not exist.
|
||||||
*/
|
*/
|
||||||
public static MultiDoku getSavedMultiDoku(int numberSave) throws Exception {
|
public static MultiDoku getSavedMultiDoku(int numberSave) throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user