feat: better shared contraints and backtrace working !

This commit is contained in:
2025-02-08 17:34:46 +01:00
parent bf9bfc8323
commit f002667e54
4 changed files with 330 additions and 169 deletions

View File

@@ -11,12 +11,21 @@ import sudoku.core.Console;
public class Sudoku {
private final Grille grille;
private final List<Contrainte> contraintes;
private String nom;
public Sudoku(int taille) {
this.grille = new Grille(taille, this);
this.contraintes = new ArrayList<>();
}
public void setNom(String nom) {
this.nom = nom;
}
public String getNom() {
return this.nom;
}
public void ajouterContrainte(Contrainte contrainte) {
contraintes.add(contrainte);
}
@@ -34,6 +43,18 @@ public class Sudoku {
return true;
}
public boolean estValide() {
for (int i = 0; i < this.getGrille().getTaille(); i++) {
for (int j = 0; j < this.getGrille().getTaille(); j++) {
Case c = this.getGrille().getCase(i, j);
if (c.getSymbole() != null && !this.estValide(c)) {
return false;
}
}
}
return true;
}
public boolean verifierToutesContraintes() {
return grille.verifierToutesContraintes(contraintes);
}