class Brick
{
	private int color;
	private int neighbours[];
	private boolean changed;
	
	public Brick(int newColor, int brickIndex)
	{
		color = newColor;
		neighbours = new int[8];
		changed = false;
		
		if((brickIndex == 0) || (brickIndex == 8) || (brickIndex == 16) || (brickIndex == 24) ||
		(brickIndex == 32) || (brickIndex == 40) || (brickIndex == 48) ||
		(brickIndex == 56))
		{
			neighbours[0] = -1;
			neighbours[1] = brickIndex - 8;
			neighbours[2] = brickIndex - 7;
			neighbours[3] = -1;
			neighbours[4] = brickIndex + 1;
			neighbours[5] = -1;
			neighbours[6] = brickIndex + 8;
			neighbours[7] = brickIndex + 9;
		}
		else if((brickIndex == 7) || (brickIndex == 15) || (brickIndex == 23) ||
		(brickIndex == 31) || (brickIndex == 39) || (brickIndex == 47) ||
		(brickIndex == 55))
		{
			neighbours[0] = brickIndex - 9;
			neighbours[1] = brickIndex - 8;
			neighbours[2] = -1;
			neighbours[3] = brickIndex - 1;
			neighbours[4] = -1;
			neighbours[5] = brickIndex + 7;
			neighbours[6] = brickIndex + 8;
			neighbours[7] = -1;
		}
		else
		{
			neighbours[0] = brickIndex - 9;
			neighbours[1] = brickIndex - 8;
			neighbours[2] = brickIndex - 7;
			neighbours[3] = brickIndex - 1;
			neighbours[4] = brickIndex + 1;
			neighbours[5] = brickIndex + 7;
			neighbours[6] = brickIndex + 8;
			neighbours[7] = brickIndex + 9;
		}	
	}
		
	public int getNeighbour(int direction)
	{
		return neighbours[direction];
	}
	
	public void setColor(int newColor)
	{
		color = newColor;
	}
	
	public int getColor()
	{
		return color;
	}
	
	public boolean isChanged()
	{
		return changed;
	}
	
	public void setChanged()
	{
		changed = true;
	}
	
	public void clearChanged()
	{
		changed = false;
	}
}
