Gwendal in main : add test on futur constraints and enhance input symbol method #1
@@ -44,5 +44,9 @@ public class App {
|
|||||||
|
|
||||||
System.out.println("Symboles possibles :");
|
System.out.println("Symboles possibles :");
|
||||||
sudoku.getGrille().printSymbolesPossibles();
|
sudoku.getGrille().printSymbolesPossibles();
|
||||||
|
|
||||||
|
//Création d'un second sudoku
|
||||||
|
Sudoku sudoku2 = new Sudoku(9);
|
||||||
|
sudoku2.getGrille().askSetSymbolesPossibles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,20 +107,20 @@ public class Grille {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void askSetSymbolesPossibles() {
|
public void askSetSymbolesPossibles() {
|
||||||
try (Scanner scanner = new Scanner(System.in)) {
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
try{
|
||||||
System.out.println(("Choisissez le type de symboles :"));
|
System.out.println(("Choisissez le type de symboles :"));
|
||||||
System.out.println(("1. Nombres"));
|
System.out.println(("1. Nombres"));
|
||||||
System.out.println(("2. Caractères"));
|
System.out.println(("2. Caractères"));
|
||||||
System.out.println(("3. Texte/Emoji"));
|
System.out.println(("3. Texte/Emoji"));
|
||||||
|
|
||||||
int choix = 0;
|
int choix = 0;
|
||||||
try {
|
try {
|
||||||
choix = Integer.parseInt(scanner.nextLine());
|
choix = scanner.nextInt();
|
||||||
|
scanner.nextLine();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Console.errorln("Choix invalide");
|
Console.errorln("Choix invalide");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < taille; i++) {
|
for (int i = 0; i < taille; i++) {
|
||||||
System.out.println(("Entrez le symbole " + (i + 1) + "/" + taille + " :"));
|
System.out.println(("Entrez le symbole " + (i + 1) + "/" + taille + " :"));
|
||||||
String input = scanner.nextLine();
|
String input = scanner.nextLine();
|
||||||
@@ -158,6 +158,10 @@ public class Grille {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
System.out.println("Une erreur est survenue : " + e.getMessage());
|
||||||
|
}finally {
|
||||||
|
scanner.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,43 +13,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
public class AppTest {
|
public class AppTest {
|
||||||
@Test
|
@Test
|
||||||
public void testExample() {
|
public void testExample() {
|
||||||
//Grille.askSetSymbolesPossibles();
|
|
||||||
System.out.println("DOING TEST");
|
System.out.println("DOING TEST");
|
||||||
System.out.println(new App().getGreeting());
|
System.out.println(new App().getGreeting());
|
||||||
|
|
||||||
// Create a new Sudoku
|
// Create a new Sudoku
|
||||||
Sudoku sudoku = new Sudoku(9);
|
Sudoku sudoku = new Sudoku(9);
|
||||||
sudoku.getGrille().setSymbolesPossibles(new ArrayList<>(Arrays.asList(
|
sudoku.getGrille().askSetSymbolesPossibles();
|
||||||
Symbole.of(1),
|
|
||||||
Symbole.of(2),
|
|
||||||
Symbole.of(3),
|
|
||||||
Symbole.of(4),
|
|
||||||
Symbole.of(5),
|
|
||||||
Symbole.of(6),
|
|
||||||
Symbole.of(7),
|
|
||||||
Symbole.of(8),
|
|
||||||
Symbole.of(9))));
|
|
||||||
|
|
||||||
sudoku.getGrille().setCase(0, 0, Symbole.of(1));
|
|
||||||
sudoku.getGrille().setCase(6, 1, Symbole.of(2));
|
|
||||||
sudoku.getGrille().setCase(2, 2, Symbole.of(3));
|
|
||||||
sudoku.getGrille().setCase(0, 3, Symbole.of(4));
|
|
||||||
sudoku.getGrille().setCase(4, 4, Symbole.of(5));
|
|
||||||
sudoku.getGrille().setCase(0, 5, Symbole.of(6));
|
|
||||||
sudoku.getGrille().setCase(5, 6, Symbole.of(7));
|
|
||||||
sudoku.getGrille().setCase(0, 7, Symbole.of(8));
|
|
||||||
sudoku.getGrille().setCase(4, 8, Symbole.of(9));
|
|
||||||
|
|
||||||
sudoku.getGrille().createSquareBlocs();
|
|
||||||
|
|
||||||
System.out.println("Sudoku :");
|
|
||||||
System.out.println(sudoku.getGrille().toString());
|
|
||||||
|
|
||||||
System.out.println("Blocs :");
|
|
||||||
sudoku.getGrille().printBlocs();
|
|
||||||
|
|
||||||
System.out.println("Symboles possibles :");
|
|
||||||
sudoku.getGrille().printSymbolesPossibles();
|
|
||||||
System.out.println("DONE TEST");
|
System.out.println("DONE TEST");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user