Exemplo n.º 1
0
 public Board(Bingo game)
 {
     game.RaiseNumberDrawedEvent += Game_RaiseNumberDrawedEvent;
     Game    = game;
     Rows    = new List <Row>(game.BoardSize);
     Columns = new List <Column>(game.BoardSize);
     for (int i = 0; i < game.BoardSize; i++)
     {
         Rows.Add(new(game, this));
         Columns.Add(new(game, this));
     }
     Cells = new Dictionary <int, Cell>(game.BoardSize * game.BoardSize);
 }
Exemplo n.º 2
0
        public Bingo ParseFile(string filePath)
        {
            var   game     = new Bingo();
            var   mode     = 0;
            var   lastMode = mode;
            Board board    = null;

            foreach (var line in ReadData(filePath))
            {
                if (string.IsNullOrWhiteSpace(line))
                {
                    mode++;
                    continue;
                }
                if (mode == 0)
                {
                    var numbers = line.Split(',').Select(s => Convert.ToInt32(s));
                    game.DrawnNumbers.AddRange(numbers);
                    continue;
                }
                var cellnumbers = line.Split(' ', StringSplitOptions.RemoveEmptyEntries).Select(s => Convert.ToInt32(s));
                if (mode == 1)
                {
                    game.BoardSize = cellnumbers.Count();
                }
                if (mode != lastMode)
                {
                    board = new Board(game)
                    {
                        BoardNumber = lastMode
                    };
                    game.Boards.Add(board);
                    lastMode = mode;
                }
                foreach (var n in cellnumbers)
                {
                    board.AddCell(n);
                }
            }
            return(game);
        }
Exemplo n.º 3
0
 public Row(Bingo game, Board board)
 {
     Cells = new List <Cell>(game.BoardSize);
     Board = board;
 }