doc : Block, Cell, Coordiante, MultiDoku
Some checks failed
Linux arm64 / Build (push) Has been cancelled
Some checks failed
Linux arm64 / Build (push) Has been cancelled
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
package sudoku.structure;
|
||||
|
||||
import sudoku.constraint.IConstraint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -12,20 +10,37 @@ import java.util.List;
|
||||
*/
|
||||
public class MultiDoku {
|
||||
|
||||
/**
|
||||
* Liste des sous-Sudoku contenue dans le multidoku.
|
||||
*/
|
||||
private final List<Sudoku> subGrids;
|
||||
|
||||
public MultiDoku(List<Sudoku> subGrids) {
|
||||
this.subGrids = subGrids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie le nombre de sudoku contenu dans ce MultiDoku.
|
||||
* @return int
|
||||
*/
|
||||
public int getNbSubGrids(){
|
||||
return subGrids.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie la ie sudoku contenue dans ce MultiDoku.
|
||||
* @param i int, indice du sudoku à renvoyer.
|
||||
* @return Sudoku, ie Sudoku
|
||||
*/
|
||||
public Sudoku getSubGrid(int i){
|
||||
return subGrids.get(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie la liste des Cells contenue dans ce MultiDoku,
|
||||
* soit les Cells contenues de chaques sous-Sudoku.
|
||||
* @return List<Cell>
|
||||
*/
|
||||
public List<Cell> getCells(){
|
||||
List<Cell> cells = new ArrayList<>();
|
||||
for (Sudoku sudoku : subGrids){
|
||||
@@ -34,6 +49,10 @@ public class MultiDoku {
|
||||
return cells;
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour les symboles possibles de chaque Cell.
|
||||
* @throws Exception, si ce n'est pas possible.
|
||||
*/
|
||||
public void updateSymbolsPossibilities() throws Exception {
|
||||
for (Sudoku sudoku : subGrids){
|
||||
sudoku.updateSymbolsPossibilities();
|
||||
@@ -51,16 +70,11 @@ public class MultiDoku {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public Cell getFirstEmptyCell() {
|
||||
for (Sudoku sudoku : this.subGrids) {
|
||||
Cell cellTmp = sudoku.getFirstEmptyCell();
|
||||
if (cellTmp != null && cellTmp.isEmpty()) {
|
||||
return cellTmp;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie les symboles possibles d'une Cell donnée.
|
||||
* @param cellToFill Cell.
|
||||
* @return List<Integer>, liste des symboles possible.
|
||||
*/
|
||||
public List<Integer> getPossibleSymbolsOfCell(Cell cellToFill) {
|
||||
List<Integer> result = new ArrayList<>();
|
||||
boolean hasBeenFill = false;
|
||||
@@ -78,10 +92,18 @@ public class MultiDoku {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie les sous-Sudoku
|
||||
* @return List<Sudoku>
|
||||
*/
|
||||
public List<Sudoku> getSubGrids() {
|
||||
return this.subGrids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check si le MultiDoku est valide, en fonction de ses sous-Sudokus.
|
||||
* @return boolean, true s'il est valide et false sinon.
|
||||
*/
|
||||
public boolean isValid() {
|
||||
boolean result = true;
|
||||
for (Sudoku sudoku : this.subGrids) {
|
||||
@@ -109,16 +131,38 @@ public class MultiDoku {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie la 1re Cell vide des sous-Sudoku.
|
||||
* @return Cell, une Cell vide, ou null s'il n'y en a pas.
|
||||
*/
|
||||
public Cell getFirstEmptyCell() {
|
||||
for (Sudoku sudoku : this.subGrids) {
|
||||
Cell cellTmp = sudoku.getFirstEmptyCell();
|
||||
if (cellTmp != null && cellTmp.isEmpty()) {
|
||||
return cellTmp;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie la liste des Cells préalablement remplies du MultiDoku.
|
||||
* @return List<Cell>, vide si aucune Cell n'est remplie.
|
||||
*/
|
||||
public List<Cell> getFilledCells() {
|
||||
List<Cell> result = new ArrayList<>();
|
||||
for (Cell c : this.getCells()){
|
||||
if (!c.isEmpty()) {
|
||||
result.add(c);
|
||||
for (Cell cell : this.getCells()){
|
||||
if (!cell.isEmpty()) {
|
||||
result.add(cell);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vide une Cell donnée.
|
||||
* @param cell Cell, à vider.
|
||||
*/
|
||||
public void empty(Cell cell) {
|
||||
List<Cell> cells = getCells();
|
||||
Cell cellToEmpty = cells.get(cells.indexOf(cell));
|
||||
|
||||
Reference in New Issue
Block a user