This commit is contained in:
80
app/src/main/java/sudoku/structure/Cell.java
Normal file
80
app/src/main/java/sudoku/structure/Cell.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package sudoku.structure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Cell {
|
||||
|
||||
public static int NOSYMBOL = -1;
|
||||
|
||||
private Block blockContainer;
|
||||
private int symbolIndex = Cell.NOSYMBOL;
|
||||
private final List<Integer> possibleSymbols;
|
||||
private boolean isMutable = true;
|
||||
|
||||
public Cell() {
|
||||
this.possibleSymbols = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Cell(int symbolIndex) {
|
||||
this.symbolIndex = symbolIndex;
|
||||
this.possibleSymbols = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Cell(int symbolIndex, boolean isMutable) {
|
||||
this.symbolIndex = symbolIndex;
|
||||
this.possibleSymbols = new ArrayList<>();
|
||||
this.isMutable = isMutable;
|
||||
}
|
||||
|
||||
public int getSymbolIndex() {
|
||||
return this.symbolIndex;
|
||||
}
|
||||
|
||||
public void setSymbolIndex(int symbolIndex) {
|
||||
this.symbolIndex = symbolIndex;
|
||||
}
|
||||
|
||||
public void setPossibleSymbols(List<Integer> possibleSymbols) {
|
||||
this.possibleSymbols.clear();
|
||||
this.possibleSymbols.addAll(possibleSymbols);
|
||||
}
|
||||
|
||||
public void setImmutable() {
|
||||
this.isMutable = false;
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return this.blockContainer;
|
||||
}
|
||||
|
||||
public void setBlock(Block block) {
|
||||
this.blockContainer = block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the current symbolIndex and returns it
|
||||
* @return integer symbolIndex cleared
|
||||
*/
|
||||
public int clearCurrentSymbol() {
|
||||
int i = this.symbolIndex;
|
||||
setSymbolIndex(NOSYMBOL);
|
||||
return i;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.symbolIndex == Cell.NOSYMBOL;
|
||||
}
|
||||
|
||||
public void removeSymbolFromPossibilities(int indexSymbol) {
|
||||
possibleSymbols.remove(indexSymbol);
|
||||
}
|
||||
|
||||
public List<Integer> getPossibleSymbols() {
|
||||
return this.possibleSymbols;
|
||||
}
|
||||
|
||||
public boolean isMutable() {
|
||||
return this.isMutable;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user