Gwendal in main : add test on futur constraints and enhance input symbol method (#1)
Co-authored-by: ROGER <gwendal.roger@etu.univ-lyon1.fr> Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
@@ -44,5 +44,14 @@ 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
|
||||||
|
System.out.println("Création d'un second SUDOKU");
|
||||||
|
|
||||||
|
Sudoku sudoku2 = new Sudoku(9);
|
||||||
|
sudoku2.getGrille().askSetSymbolesPossibles();
|
||||||
|
|
||||||
|
System.out.println("Symboles possibles :");
|
||||||
|
sudoku2.getGrille().printSymbolesPossibles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,161 +12,183 @@ public class Grille {
|
|||||||
private final ArrayList<Bloc> blocs;
|
private final ArrayList<Bloc> blocs;
|
||||||
private ArrayList<Symbole> symbolesPossibles;
|
private ArrayList<Symbole> symbolesPossibles;
|
||||||
|
|
||||||
public Grille(int taille) {
|
public Grille(int taille) {
|
||||||
this.taille = taille;
|
this.taille = taille;
|
||||||
this.cases = new Case[taille][taille];
|
this.cases = new Case[taille][taille];
|
||||||
this.blocs = new ArrayList<>();
|
this.blocs = new ArrayList<>();
|
||||||
this.symbolesPossibles = new ArrayList<>();
|
this.symbolesPossibles = new ArrayList<>();
|
||||||
|
|
||||||
// Initialiser les cases
|
// Initialiser les cases
|
||||||
for (int i = 0; i < taille; i++) {
|
for (int i = 0; i < taille; i++) {
|
||||||
for (int j = 0; j < taille; j++) {
|
for (int j = 0; j < taille; j++) {
|
||||||
cases[i][j] = new Case(i, j, null);
|
cases[i][j] = new Case(i, j, null);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setCase(int ligne, int colonne, Symbole symbole) {
|
public void setCase(int ligne, int colonne, Symbole symbole) {
|
||||||
try {
|
try {
|
||||||
if (symbole != null && !symbolesPossibles.contains(symbole)) {
|
if (symbole != null && !symbolesPossibles.contains(symbole)) {
|
||||||
throw new IllegalArgumentException("Symbole non autorisé : " + symbole);
|
throw new IllegalArgumentException("Symbole non autorisé : " + symbole);
|
||||||
}
|
|
||||||
cases[ligne][colonne].setSymbole(symbole);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Console.errorln(e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
cases[ligne][colonne].setSymbole(symbole);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Console.errorln(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Case getCase(int ligne, int colonne) {
|
}
|
||||||
return cases[ligne][colonne];
|
|
||||||
|
public Case getCase(int ligne, int colonne) {
|
||||||
|
return cases[ligne][colonne];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crée un bloc à partir des positions spécifiées
|
||||||
|
*
|
||||||
|
* Exemple :
|
||||||
|
* sudoku.getGrille().createBloc(Arrays.asList(
|
||||||
|
* new int[] { 0, 0 },
|
||||||
|
* new int[] { 0, 1 },
|
||||||
|
* new int[] { 0, 2 },
|
||||||
|
* new int[] { 1, 0 },
|
||||||
|
* new int[] { 1, 1 },
|
||||||
|
* new int[] { 1, 2 },
|
||||||
|
* new int[] { 2, 0 },
|
||||||
|
* new int[] { 2, 1 },
|
||||||
|
* new int[] { 2, 2 }));
|
||||||
|
*
|
||||||
|
* @param positions
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Bloc createBloc(List<int[]> positions) {
|
||||||
|
Bloc bloc = new Bloc();
|
||||||
|
for (int[] pos : positions) {
|
||||||
|
bloc.addCase(cases[pos[0]][pos[1]]);
|
||||||
}
|
}
|
||||||
|
blocs.add(bloc);
|
||||||
|
return bloc;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public void createSquareBlocs() {
|
||||||
* Crée un bloc à partir des positions spécifiées
|
try {
|
||||||
|
int blocSize = (int) Math.sqrt(taille);
|
||||||
Exemple :
|
if (blocSize * blocSize != taille) {
|
||||||
sudoku.getGrille().createBloc(Arrays.asList(
|
throw new IllegalArgumentException("La taille de la grille doit être un carré parfait.");
|
||||||
new int[] { 0, 0 },
|
|
||||||
new int[] { 0, 1 },
|
|
||||||
new int[] { 0, 2 },
|
|
||||||
new int[] { 1, 0 },
|
|
||||||
new int[] { 1, 1 },
|
|
||||||
new int[] { 1, 2 },
|
|
||||||
new int[] { 2, 0 },
|
|
||||||
new int[] { 2, 1 },
|
|
||||||
new int[] { 2, 2 }));
|
|
||||||
* @param positions
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Bloc createBloc(List<int[]> positions) {
|
|
||||||
Bloc bloc = new Bloc();
|
|
||||||
for (int[] pos : positions) {
|
|
||||||
bloc.addCase(cases[pos[0]][pos[1]]);
|
|
||||||
}
|
}
|
||||||
blocs.add(bloc);
|
for (int i = 0; i < taille; i += blocSize) {
|
||||||
return bloc;
|
for (int j = 0; j < taille; j += blocSize) {
|
||||||
}
|
List<int[]> positions = new ArrayList<>();
|
||||||
|
for (int k = 0; k < blocSize; k++) {
|
||||||
public void createSquareBlocs() {
|
for (int l = 0; l < blocSize; l++) {
|
||||||
try {
|
positions.add(new int[] { i + k, j + l });
|
||||||
int blocSize = (int) Math.sqrt(taille);
|
|
||||||
if (blocSize * blocSize != taille) {
|
|
||||||
throw new IllegalArgumentException("La taille de la grille doit être un carré parfait.");
|
|
||||||
}
|
|
||||||
for (int i = 0; i < taille; i += blocSize) {
|
|
||||||
for (int j = 0; j < taille; j += blocSize) {
|
|
||||||
List<int[]> positions = new ArrayList<>();
|
|
||||||
for (int k = 0; k < blocSize; k++) {
|
|
||||||
for (int l = 0; l < blocSize; l++) {
|
|
||||||
positions.add(new int[] { i + k, j + l });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
createBloc(positions);
|
|
||||||
}
|
}
|
||||||
|
createBloc(positions);
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
Console.errorln(e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Console.errorln(e.getMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TO MOVE TO FUTUR CONSTRAINTS
|
// TO MOVE TO FUTUR CONSTRAINTS
|
||||||
// public boolean isValid() {
|
// public boolean isValid() {
|
||||||
// for (Bloc bloc : blocs) {
|
// for (Bloc bloc : blocs) {
|
||||||
// if (!bloc.isValid()) {
|
// if (!bloc.isValid()) {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// return true;
|
// return true;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public void printBlocs() {
|
public void printBlocs() {
|
||||||
for (Bloc bloc : blocs) {
|
for (Bloc bloc : blocs) {
|
||||||
System.out.println(bloc.toString());
|
System.out.println(bloc.toString());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void askSetSymbolesPossibles() {
|
public void askSetSymbolesPossibles() {
|
||||||
try (Scanner scanner = new Scanner(System.in)) {
|
Scanner scanner = new Scanner(System.in);
|
||||||
System.out.println(("Choisissez le type de symboles :"));
|
try {
|
||||||
System.out.println(("1. Nombres"));
|
Console.infoln("Choisissez le type de symboles :");
|
||||||
System.out.println(("2. Caractères"));
|
Console.infoln("1. Nombres");
|
||||||
System.out.println(("3. Texte/Emoji"));
|
Console.infoln("2. Lettres");
|
||||||
|
Console.infoln("3. Texte/Emoji");
|
||||||
|
|
||||||
int choix = 0;
|
int choix = 0;
|
||||||
try {
|
try {
|
||||||
choix = Integer.parseInt(scanner.nextLine());
|
choix = Integer.parseInt(scanner.nextLine());
|
||||||
} catch (NumberFormatException e) {
|
if (choix < 1 || choix > 3) {
|
||||||
Console.errorln("Choix invalide");
|
throw new NumberFormatException("Choix invalide");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
Console.errorln("Choix invalide");
|
||||||
|
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();
|
||||||
|
|
||||||
switch (choix) {
|
switch (choix) {
|
||||||
case 1: // Nombres
|
case 1: // Nombres
|
||||||
try {
|
Symbole intTemp = Symbole.of(input);
|
||||||
symbolesPossibles.add(Symbole.of(Integer.parseInt(input)));
|
if (intTemp.isInt()) {
|
||||||
} catch (NumberFormatException e) {
|
if (symbolesPossibles.contains(intTemp)) {
|
||||||
Console.errorln("Veuillez entrer un nombre valide");
|
Console.errorln("Ce symbole existe déjà, veuillez entrer un autre symbole");
|
||||||
i--;
|
i--;
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2: // Caractères
|
|
||||||
if (input.length() == 1) {
|
|
||||||
symbolesPossibles.add(Symbole.of(input.charAt(0)));
|
|
||||||
} else {
|
} else {
|
||||||
Console.errorln("Veuillez entrer un seul caractère");
|
symbolesPossibles.add(intTemp);
|
||||||
i--;
|
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
|
Console.errorln("Veuillez entrer un nombre valide");
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 3: // Texte/Emoji
|
case 2: // Lettres
|
||||||
if (!input.isEmpty()) {
|
if (input.length() == 1 && Symbole.of(input.charAt(0)).isLetter()) {
|
||||||
symbolesPossibles.add(Symbole.of(input));
|
Symbole charTemp = Symbole.of(input.charAt(0));
|
||||||
|
if (symbolesPossibles.contains(charTemp)) {
|
||||||
|
Console.errorln("Ce symbole existe déjà, veuillez entrer un autre symbole");
|
||||||
|
i--;
|
||||||
} else {
|
} else {
|
||||||
Console.errorln("Le symbole ne peut pas être vide");
|
symbolesPossibles.add(charTemp);
|
||||||
i--;
|
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
|
Console.errorln("Veuillez entrer une lettre valide");
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
case 3: // Texte/Emoji
|
||||||
Console.errorln("Type non supporté");
|
Symbole stringTemp = Symbole.of(input);
|
||||||
return;
|
if (symbolesPossibles.contains(stringTemp)) {
|
||||||
}
|
Console.errorln("Ce symbole existe déjà, veuillez entrer un autre symbole");
|
||||||
|
i--;
|
||||||
|
} else {
|
||||||
|
symbolesPossibles.add(stringTemp);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Console.errorln("Type non supporté");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("Une erreur est survenue : " + e.getMessage());
|
||||||
|
} finally {
|
||||||
|
scanner.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<Symbole> getSymbolesPossibles() {
|
public List<Symbole> getSymbolesPossibles() {
|
||||||
return symbolesPossibles;
|
return symbolesPossibles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSymbolesPossibles(ArrayList<Symbole> symbolesPossibles) {
|
public void setSymbolesPossibles(ArrayList<Symbole> symbolesPossibles) {
|
||||||
this.symbolesPossibles = symbolesPossibles;
|
this.symbolesPossibles = symbolesPossibles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printSymbolesPossibles() {
|
public void printSymbolesPossibles() {
|
||||||
|
|||||||
@@ -20,6 +20,19 @@ public class Symbole {
|
|||||||
return new Symbole(String.valueOf(c));
|
return new Symbole(String.valueOf(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInt() {
|
||||||
|
try {
|
||||||
|
Integer.parseInt(valeur);
|
||||||
|
return true;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLetter() {
|
||||||
|
return valeur.length() == 1 && Character.isLetter(valeur.charAt(0));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return valeur;
|
return valeur;
|
||||||
@@ -27,8 +40,11 @@ public class Symbole {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj) return true;
|
if (this == obj)
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
return true;
|
||||||
|
|
||||||
|
if (obj == null || getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
Symbole symbole = (Symbole) obj;
|
Symbole symbole = (Symbole) obj;
|
||||||
return valeur.equals(symbole.valeur);
|
return valeur.equals(symbole.valeur);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,18 @@ public class Console {
|
|||||||
static final String ANSI_BOLD = "\u001B[1m";
|
static final String ANSI_BOLD = "\u001B[1m";
|
||||||
|
|
||||||
public static void errorln(String message) {
|
public static void errorln(String message) {
|
||||||
System.err.println(ANSI_RED + ANSI_BOLD + message + ANSI_RESET);
|
System.err.println(ANSI_RED + ANSI_BOLD + message + ANSI_RESET + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void successln(String message) {
|
public static void successln(String message) {
|
||||||
System.out.println(ANSI_GREEN + ANSI_BOLD + message + ANSI_RESET);
|
System.out.println(ANSI_GREEN + ANSI_BOLD + message + ANSI_RESET + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void warnln(String message) {
|
public static void warnln(String message) {
|
||||||
System.out.println(ANSI_YELLOW + ANSI_BOLD+ message + ANSI_RESET);
|
System.out.println(ANSI_YELLOW + ANSI_BOLD + message + ANSI_RESET + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void infoln(String message) {
|
||||||
|
System.out.println(message + "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,35 @@
|
|||||||
/*
|
|
||||||
* This Java source file was generated by the Gradle 'init' task.
|
|
||||||
*/
|
|
||||||
package sudoku;
|
package sudoku;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
public class AppTest {
|
public class AppTest {
|
||||||
@Test
|
@Test
|
||||||
public void testExample() {
|
public void testExample() {
|
||||||
System.out.println("DOING TEST");
|
// Simulate user input
|
||||||
assertEquals(2 + 2, 4);
|
String simulatedInput = "1\n1\n2\n3\n4\n5\n6\n7\n8\n9\n";
|
||||||
System.out.println("DONE TEST");
|
System.setIn(new ByteArrayInputStream(simulatedInput.getBytes()));
|
||||||
|
|
||||||
|
// Create a new Sudoku
|
||||||
|
Sudoku sudoku = new Sudoku(9);
|
||||||
|
sudoku.getGrille().askSetSymbolesPossibles();
|
||||||
|
|
||||||
|
// Verify the symbols
|
||||||
|
ArrayList<Symbole> expectedSymbols = 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)));
|
||||||
|
assertEquals(expectedSymbols, sudoku.getGrille().getSymbolesPossibles());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
50
app/src/test/java/sudoku/TestBloc.java
Normal file
50
app/src/test/java/sudoku/TestBloc.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package sudoku;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class TestBloc {
|
||||||
|
@Test
|
||||||
|
public void testBloc() {
|
||||||
|
System.out.println("TEST BLOC : ");
|
||||||
|
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().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));
|
||||||
|
//doublon bloc
|
||||||
|
sudoku.getGrille().setCase(1, 1, Symbole.of(1));
|
||||||
|
|
||||||
|
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("FIN TEST BLOC");
|
||||||
|
}
|
||||||
|
}
|
||||||
50
app/src/test/java/sudoku/TestColonne.java
Normal file
50
app/src/test/java/sudoku/TestColonne.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package sudoku;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class TestColonne {
|
||||||
|
@Test
|
||||||
|
public void testColonne() {
|
||||||
|
System.out.println("TEST COL : ");
|
||||||
|
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().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));
|
||||||
|
// doublon colonne
|
||||||
|
sudoku.getGrille().setCase(4, 0, Symbole.of(1));
|
||||||
|
|
||||||
|
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("FIN TEST COL");
|
||||||
|
}
|
||||||
|
}
|
||||||
50
app/src/test/java/sudoku/TestLigne.java
Normal file
50
app/src/test/java/sudoku/TestLigne.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package sudoku;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class TestLigne {
|
||||||
|
@Test
|
||||||
|
public void testLigne() {
|
||||||
|
System.out.println("TEST LIGNE : ");
|
||||||
|
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().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));
|
||||||
|
//doublon ligne
|
||||||
|
sudoku.getGrille().setCase(0, 4, Symbole.of(1));
|
||||||
|
|
||||||
|
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("FIN TEST LIGNE");
|
||||||
|
}
|
||||||
|
}
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
Reference in New Issue
Block a user