This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
package sudoku;
|
package sudoku;
|
||||||
|
|
||||||
public class Cell {
|
public abstract class Cell {
|
||||||
|
|
||||||
private static int NOSYMBOLE = -1;
|
protected static int NOSYMBOLE = -1;
|
||||||
private int symboleIndex;
|
protected int symboleIndex;
|
||||||
private Block block = null;
|
protected Block block = null;
|
||||||
|
|
||||||
public Cell(int symboleIndex) {
|
public Cell(int symboleIndex) {
|
||||||
this.symboleIndex = symboleIndex;
|
this.symboleIndex = symboleIndex;
|
||||||
@@ -21,14 +21,6 @@ public class Cell {
|
|||||||
return symboleIndex;
|
return symboleIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSymboleIndex(int symboleIndex) {
|
|
||||||
this.symboleIndex = symboleIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear() {
|
|
||||||
setSymboleIndex(NOSYMBOLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Block getBlock() {
|
public Block getBlock() {
|
||||||
return this.block;
|
return this.block;
|
||||||
}
|
}
|
||||||
|
|||||||
9
app/src/main/java/sudoku/ImmutableCell.java
Normal file
9
app/src/main/java/sudoku/ImmutableCell.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package sudoku;
|
||||||
|
|
||||||
|
public class ImmutableCell extends Cell {
|
||||||
|
|
||||||
|
public ImmutableCell(int symboleIndex) {
|
||||||
|
super(symboleIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
32
app/src/main/java/sudoku/MutableCell.java
Normal file
32
app/src/main/java/sudoku/MutableCell.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ public class SudokuFactory {
|
|||||||
private static List<Cell> initCells(int size) {
|
private static List<Cell> initCells(int size) {
|
||||||
List<Cell> cells = new ArrayList<>(size * size);
|
List<Cell> cells = new ArrayList<>(size * size);
|
||||||
for (int i = 0; i < size * size; i++) {
|
for (int i = 0; i < size * size; i++) {
|
||||||
cells.add(new Cell());
|
cells.add(new MutableCell());
|
||||||
}
|
}
|
||||||
return cells;
|
return cells;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user