03/01/2025 : Création d'un second sudoku avec intégration automatique des symboles

This commit is contained in:
ROGER
2025-01-03 17:12:10 +01:00
parent a1b130b968
commit b553fd2be9
3 changed files with 13 additions and 35 deletions

View File

@@ -44,5 +44,9 @@ public class App {
System.out.println("Symboles possibles :");
sudoku.getGrille().printSymbolesPossibles();
//Création d'un second sudoku
Sudoku sudoku2 = new Sudoku(9);
sudoku2.getGrille().askSetSymbolesPossibles();
}
}

View File

@@ -107,20 +107,20 @@ public class Grille {
}
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(("1. Nombres"));
System.out.println(("2. Caractères"));
System.out.println(("3. Texte/Emoji"));
int choix = 0;
try {
choix = Integer.parseInt(scanner.nextLine());
choix = scanner.nextInt();
scanner.nextLine();
} catch (NumberFormatException e) {
Console.errorln("Choix invalide");
return;
}
for (int i = 0; i < taille; i++) {
System.out.println(("Entrez le symbole " + (i + 1) + "/" + taille + " :"));
String input = scanner.nextLine();
@@ -158,6 +158,10 @@ public class Grille {
return;
}
}
}catch (Exception e) {
System.out.println("Une erreur est survenue : " + e.getMessage());
}finally {
scanner.close();
}
}

View File

@@ -13,43 +13,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
public class AppTest {
@Test
public void testExample() {
//Grille.askSetSymbolesPossibles();
System.out.println("DOING TEST");
System.out.println(new App().getGreeting());
// Create a new Sudoku
Sudoku sudoku = new Sudoku(9);
sudoku.getGrille().setSymbolesPossibles(new ArrayList<>(Arrays.asList(
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().askSetSymbolesPossibles();
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");
}
}