ANGLICHE
All checks were successful
Linux arm64 / Build (push) Successful in 34s

This commit is contained in:
2025-01-10 16:14:52 +01:00
parent 77c0b0d41b
commit 8cd0f6fa12
8 changed files with 68 additions and 74 deletions

View File

@@ -5,38 +5,38 @@ import java.util.List;
public class SudokuFactory {
private static List<Case> initCases(int size) {
List<Case> cases = new ArrayList<>(size * size);
private static List<Cell> initCells(int size) {
List<Cell> cells = new ArrayList<>(size * size);
for (int i = 0; i < size * size; i++) {
cases.add(new Case());
cells.add(new Cell());
}
return cases;
return cells;
}
private static List<Bloc> initRectangleBlocs(List<Case> cases, int width, int height) {
List<Bloc> blocs = new ArrayList<>();
private static List<Block> initRectangleBlocs(List<Cell> cells, int width, int height) {
List<Block> blocs = new ArrayList<>();
int size = width * height;
for (int i = 0; i < size; i++) {
Bloc newBloc = new Bloc();
int blocX = i % height;
int blocY = i / height;
Block newBlock = new Block();
int blockX = i % height;
int blockY = i / height;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int index = ((y + blocY * height) * size + (x + blocX * width));
Case caseBloc = cases.get(index);
caseBloc.setBloc(newBloc);
newBloc.addCase(caseBloc);
int index = ((y + blockY * height) * size + (x + blockX * width));
Cell blockCell = cells.get(index);
blockCell.setBlock(newBlock);
newBlock.addCell(blockCell);
}
}
blocs.add(newBloc);
blocs.add(newBlock);
}
return blocs;
}
public static MultiDoku createBasicEmptyRectangleSudoku(int width, int height) {
int symbolCount = width * height;
List<Case> cases = initCases(symbolCount);
List<Bloc> blocs = initRectangleBlocs(cases, width, height);
List<Cell> cases = initCells(symbolCount);
List<Block> blocs = initRectangleBlocs(cases, width, height);
Sudoku s = new Sudoku(cases, blocs);
List<Sudoku> ss = new ArrayList<>();
ss.add(s);