package sudoku;

public abstract class Cell {

	protected static int NOSYMBOLE = -1;
	protected int symbolIndex;
	protected Block block = null;

	public Cell(int symbolIndex) {
		this.symbolIndex = symbolIndex;
	}

	/**
	 * @brief Default constructor, empty square
	 */
	public Cell() {
		this(NOSYMBOLE);
	}

	public int getSymbolIndex() {
		return symbolIndex;
	}

	public Block getBlock() {
		return this.block;
	}

	// only SudokuFactory and SudokuSerializer should access this
	public void setBlock(Block block) {
		this.block = block;
	}

	public boolean equalsValue(Cell otherCell) {
		return otherCell.getSymbolIndex() == this.getSymbolIndex();
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("| ");
		if (this.symbolIndex != NOSYMBOLE){
			sb.append(this.symbolIndex);
		}
		else {
			sb.append(" ");
		}

		sb.append(" |");
		return sb.toString();
	}

}
