doc : Block, Cell, Coordiante, MultiDoku
Some checks failed
Linux arm64 / Build (push) Has been cancelled

This commit is contained in:
Melvyn
2025-01-28 11:21:43 +01:00
parent a1fd715aee
commit 5eabf87c94
5 changed files with 154 additions and 21 deletions

View File

@@ -7,14 +7,25 @@ import java.util.List;
/**
* @class Sudoku
* @brief Represents a sudoku
* @brief Représent un Sudoku
*/
public class Sudoku {
/**
* Liste des Block contenus dans le Sudoku.
*/
private final List<Block> blocks;
/**
* Liste des Cells contenus dans le Sudoku.
*/
private final List<Cell> cells;
/**
* Liste des contraintes (TODO) du Sudoku.
*/
private final List<IConstraint> constraints;
private boolean isMutable;
/**
* Largeur des Blocks s'ils sont rectangulaires, sinon ça vaut 0.
*/
private int blockWidth;
public Sudoku(List<Cell> cells, List<Block> blocks, List<IConstraint> constraints) {
@@ -23,16 +34,29 @@ public class Sudoku {
this.constraints = constraints;
}
public int[] toCoords(int index) {
return new int[] { index % getSize(), index / getSize() };
/**
* Transforme un index de Cell en Coordiante.
*
* @param index int, index d'une Cell.
* @return Coordinate, correspondante à l'index donné.
*/
public Coordinate toCoords(int index) {
return new Coordinate( index % getSize(), index / getSize() );
}
/**
* Transforme des coordonées d'une Cell en index.
* @param x int, abscisse.
* @param y int, ordonnée.
* @return int, index correspondant.
*/
public int toIndex(int x, int y) {
return y * getSize() + x;
}
/**
* @return wether the coords are in the sudoku
* Vérifie que des coordonnées correspondent bien à une Cell dans le Sudoku.
* @return boolean, wether the coords are in the sudoku
*/
public boolean isValidCoords(int x, int y) {
int index = toIndex(x, y);