This commit is contained in:
@@ -1,22 +1,12 @@
|
||||
package sudoku.constraint;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import sudoku.structure.Sudoku;
|
||||
|
||||
public interface IConstraint extends Serializable {
|
||||
/**
|
||||
* Interface de base pour la déclaration d'une contrainte
|
||||
* Elle est en théorie assez générique pour implémenter n'importe quelle
|
||||
* contrainte
|
||||
*/
|
||||
public interface IConstraint {
|
||||
boolean canBePlaced(final Sudoku s, int x, int y, int newSymbolIndex);
|
||||
|
||||
default List<Integer> getPossibleSymbols(final Sudoku s, int x, int y) {
|
||||
List<Integer> possibilities = new ArrayList<>();
|
||||
for (int i = 0; i < s.getSize(); i++) {
|
||||
if (canBePlaced(s, x, y, i)) {
|
||||
possibilities.add(i);
|
||||
}
|
||||
}
|
||||
return possibilities;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user