package clue;

public class BoardCell {
	protected Integer index, top, right, bottom, left;

	public BoardCell(int i, int rows, int cols) {
		index = i;
		// Initialize our links.
		if((index - cols) >= 0)
			top = index - cols;
		if((index + cols) < (rows*cols))
			bottom = index + cols;
		if((index % cols) > 0)
			left = index - 1;
		if(((index + 1) % cols) > 0)
			right = index + 1;
	}

	// Auto-generated by Eclipse. This lets us compare two BoardCells.
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((index == null) ? 0 : index.hashCode());
		return result;
	}

	// See above.
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BoardCell other = (BoardCell) obj;
		if (index == null) {
			if (other.index != null)
				return false;
		} else if (!index.equals(other.index))
			return false;
		return true;
	}

	// Allows us to print things like HashSet<BoardCell>s.
	public String toString() {
		return index.toString();
	}

	// By default, all of these return false.
	public boolean isWalkway() {
		return false;
	}

	public boolean isRoom() {
		return false;
	}

	public boolean isDoorway() {
		return false;
	}
}

package clue;

public class BoardCell {
	protected Integer index, top, right, bottom, left;

	public BoardCell(int i, int numRows, int numCols) {
		index = i;
		// Initialize our links.
		if((index - numCols) >= 0)
			top = index - numCols;
		if((index + numCols) < (numRows*numCols))
			bottom = index + numCols;
		if((index % numCols) > 0)
			left = index - 1;
		if(((index + 1) % numCols) > 0)
			right = index + 1;
	}

	// Auto-generated by Eclipse. This lets us compare two BoardCells.
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((index == null) ? 0 : index.hashCode());
		return result;
	}

	// See above.
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BoardCell other = (BoardCell) obj;
		if (index == null) {
			if (other.index != null)
				return false;
		} else if (!index.equals(other.index))
			return false;
		return true;
	}

	// Allows us to print things like HashSet<BoardCell>s.
	public String toString() {
		return index.toString();
	}

	// By default, all of these return false.
	public boolean isWalkway() {
		return false;
	}

	public boolean isRoom() {
		return false;
	}

	public boolean isDoorway() {
		return false;
	}
}

Change rows and cols to numRows and numCols.