This commit is contained in:
47
app/src/main/java/sudoku/Cell.java
Normal file
47
app/src/main/java/sudoku/Cell.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package sudoku;
|
||||
|
||||
public class Cell {
|
||||
|
||||
private static int NOSYMBOLE = -1;
|
||||
private int symboleIndex;
|
||||
private Block block = null;
|
||||
|
||||
public Cell(int symboleIndex) {
|
||||
this.symboleIndex = symboleIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Default constructor, empty square
|
||||
*/
|
||||
public Cell() {
|
||||
this(NOSYMBOLE);
|
||||
}
|
||||
|
||||
public int getSymboleIndex() {
|
||||
return symboleIndex;
|
||||
}
|
||||
|
||||
public void setSymboleIndex(int symboleIndex) {
|
||||
this.symboleIndex = symboleIndex;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
setSymboleIndex(NOSYMBOLE);
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return this.block;
|
||||
}
|
||||
|
||||
// only SudokuFactory should access this
|
||||
void setBlock(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Cell otherCell)
|
||||
return otherCell.getSymboleIndex() == this.getSymboleIndex();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user