}
public static ICell[] getConnectedCells(IBoard board, ICell refrenceCell) {
ArrayList<ICell> connectedCells = new ArrayList<ICell>();
ICell topCell = getConnectedTopCell(board, refrenceCell);
if (topCell != null) {
connectedCells.add(topCell);
}
ICell rightCell = getConnectedRightCell(board, refrenceCell);
if (rightCell != null) {
connectedCells.add(rightCell);
}
ICell bottomCell = getConnectedBottomCell(board, refrenceCell);
if (bottomCell != null) {
connectedCells.add(bottomCell);
}
ICell leftCell = getConnectedLeftCell(board, refrenceCell);
if (leftCell != null) {
connectedCells.add(leftCell);
}
return connectedCells.toArray(new ICell[0]);