95 lines
1.8 KiB
Java
95 lines
1.8 KiB
Java
package sudoku;
|
|
|
|
import org.checkerframework.checker.units.qual.C;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public abstract class Cell {
|
|
|
|
protected static int NOSYMBOL = -1;
|
|
protected int symbolIndex;
|
|
protected Block block = null;
|
|
//protected List<Block> blockContainers = null;
|
|
//protected List<Sudoku> sudokuContainers = null;
|
|
|
|
public Cell(int symbolIndex) {
|
|
this.symbolIndex = symbolIndex;
|
|
}
|
|
|
|
/**
|
|
* @brief Default constructor, empty square
|
|
*/
|
|
public Cell() {
|
|
this(NOSYMBOL);
|
|
}
|
|
|
|
/*
|
|
|
|
public Cell(Cell cell) {
|
|
this.symbolIndex = cell.symbolIndex;
|
|
this.sudokuContainers = cell.sudokuContainers;
|
|
this.blockContainers = cell.blockContainers;
|
|
}
|
|
|
|
public Cell(List<Sudoku> sudokuContainers, List<Block> blockContainers) {
|
|
super();
|
|
this.sudokuContainers = new ArrayList<>(sudokuContainers);
|
|
this.blockContainers = new ArrayList<>(blockContainers);
|
|
}
|
|
|
|
*/
|
|
|
|
public int getSymbolIndex() {
|
|
return symbolIndex;
|
|
}
|
|
|
|
public Block getBlock() {
|
|
return this.block;
|
|
}
|
|
|
|
/*
|
|
public List<Block> getBlockContainers() {
|
|
return this.blockContainers;
|
|
}
|
|
|
|
public void setBlockContainers(List<Block> block) {
|
|
this.blockContainers = block;
|
|
}
|
|
|
|
public List<Sudoku> getSudokuContainers() {
|
|
return this.sudokuContainers;
|
|
}
|
|
*/
|
|
// only SudokuFactory and SudokuSerializer should access this
|
|
public void setBlock(Block block) {
|
|
this.block = block;
|
|
}
|
|
|
|
/*
|
|
public void setSudokuContainers(List<Sudoku> sudoku) {
|
|
this.sudokuContainers = sudoku;
|
|
}
|
|
*/
|
|
|
|
public boolean equalsValue(Cell otherCell) {
|
|
return otherCell.getSymbolIndex() == this.getSymbolIndex();
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("| ");
|
|
if (this.symbolIndex != NOSYMBOL){
|
|
sb.append(this.symbolIndex);
|
|
}
|
|
else {
|
|
sb.append(" ");
|
|
}
|
|
|
|
sb.append(" |");
|
|
return sb.toString();
|
|
}
|
|
|
|
}
|