Ejemplo n.º 1
0
 /// <summary>
 /// Initialize the given list with new BingoCards.
 /// </summary>
 /// <param name="bingoCards">The list to initialize.</param>
 private static void InitializeBingoCards(IList <BingoCard> bingoCards)
 {
     for (int i = 0; i < bingoCards.Count(); i++)
     {
         bingoCards[i] = new BingoCard();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Play the given number of games with the bingo cards and return the average number of Bingo balls called for each game. You can register an event to get the number of Bingo balls called for each game, if desired.
        /// </summary>
        /// <param name="numberOfGames">The number of games to play.</param>
        /// <param name="numberOfBingoCards">The number of Bingo cards to play for each game.</param>
        /// <returns></returns>
        public int PlayGamesWithCards(int numberOfGames, int numberOfBingoCards)
        {
            BingoCard[] bingoCards = new BingoCard[numberOfBingoCards];

            int total = 0;

            for (int game = 0; game < numberOfGames; game++)
            {
                InitializeBingoCards(bingoCards);
                int ballsCalled = PlayGameWithCards(bingoCards);
                GameFinished(ballsCalled);
                total += ballsCalled;
            }

            return(total / numberOfGames);
        }