Exemplo n.º 1
0
        bool UpdateSeat1(Cell[,] inputGrid, Cell[,] outputGrid, int x, int y)
        {
            var cell = inputGrid[x, y];

            if (cell == Cell.EMPTY_SEAT)
            {
                if (!inputGrid.GetNeighbours(x, y).Where(c => c == Cell.TAKEN_SEAT).Any())
                {
                    outputGrid[x, y] = Cell.TAKEN_SEAT;
                    return(true);
                }
            }
            else if (cell == Cell.TAKEN_SEAT)
            {
                if (inputGrid.GetNeighbours(x, y).Where(c => c == Cell.TAKEN_SEAT).Count() >= 4)
                {
                    outputGrid[x, y] = Cell.EMPTY_SEAT;
                    return(true);
                }
            }

            outputGrid[x, y] = cell;
            return(false);
        }