feat: better shared contraints and backtrace working !
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user