Exemplo n.º 1
0
        private bool TryGetField(string dimensions, out Field field)
        {
            var width  = GetWidth(dimensions);
            var height = GetHeight(dimensions);

            field = new Field(width, height);

            for (var y = 0; y < height; y++)
            {
                var row = (string)_consoleReader.ReadLine();
                if (!ValidRow(row, width))
                {
                    return(false);
                }
                for (var x = 0; x < width; x++)
                {
                    if (row[x] == '*')
                    {
                        field.SetMine(x, y);
                    }
                }
            }

            return(true);
        }