mutable and immutable cells
Some checks failed
Linux arm64 / Build (push) Failing after 19s

This commit is contained in:
2025-01-10 16:30:25 +01:00
parent 8cd0f6fa12
commit d849f3afc4
4 changed files with 46 additions and 13 deletions

View File

@@ -1,10 +1,10 @@
package sudoku;
public class Cell {
public abstract class Cell {
private static int NOSYMBOLE = -1;
private int symboleIndex;
private Block block = null;
protected static int NOSYMBOLE = -1;
protected int symboleIndex;
protected Block block = null;
public Cell(int symboleIndex) {
this.symboleIndex = symboleIndex;
@@ -21,14 +21,6 @@ public class Cell {
return symboleIndex;
}
public void setSymboleIndex(int symboleIndex) {
this.symboleIndex = symboleIndex;
}
public void clear() {
setSymboleIndex(NOSYMBOLE);
}
public Block getBlock() {
return this.block;
}

View File

@@ -0,0 +1,9 @@
package sudoku;
public class ImmutableCell extends Cell {
public ImmutableCell(int symboleIndex) {
super(symboleIndex);
}
}

View File

@@ -0,0 +1,32 @@
package sudoku;
import java.util.ArrayList;
import java.util.List;
public class MutableCell extends Cell{
private final List<Integer> hintsSymbolIndex;
public MutableCell() {
super();
this.hintsSymbolIndex = new ArrayList<>();
}
public MutableCell(int symboleIndex) {
super(symboleIndex);
this.hintsSymbolIndex = new ArrayList<>();
}
public void setSymboleIndex(int symboleIndex) {
this.symboleIndex = symboleIndex;
}
public void clear() {
setSymboleIndex(NOSYMBOLE);
}
public List<Integer> getHints() {
return this.hintsSymbolIndex;
}
}

View File

@@ -8,7 +8,7 @@ public class SudokuFactory {
private static List<Cell> initCells(int size) {
List<Cell> cells = new ArrayList<>(size * size);
for (int i = 0; i < size * size; i++) {
cells.add(new Cell());
cells.add(new MutableCell());
}
return cells;
}