Example #1
0
 /// <summary>
 /// Builds a new round
 /// </summary>
 /// <param name="makeRoundFunction"></param>
 /// <param name="args"></param>
 /// <returns></returns>
 private RoundInfo[] MakeRounds(MakeRoundFunction makeRoundFunction, MakeRoundArgs args)
 {
     RoundInfo[] rounds = new RoundInfo[TOTAL_ROUNDS];
     for (int i = 0; i < TOTAL_ROUNDS; i++)
     {
         rounds[i] = makeRoundFunction(args.rand);
     }
     return(rounds);
 }
Example #2
0
        /// <summary>
        /// Builds a round for the multiplication game
        /// </summary>
        /// <param name="rand"></param>
        /// <returns></returns>
        private RoundInfo MakeMultiplicationRound(Random rand)
        {
            RoundInfo round = new RoundInfo();

            round.FirstOperand  = rand.Next(DIFFICULTY_MIN, DIFFICULTY_MAX + 1);
            round.SecondOperand = rand.Next(DIFFICULTY_MIN, DIFFICULTY_MAX + 1);
            round.Answer        = round.FirstOperand * round.SecondOperand;
            round.Operator      = "*";

            return(round);
        }
Example #3
0
        /// <summary>
        /// Builds a round for the division game ;)
        /// </summary>
        /// <param name="rand"></param>
        /// <returns></returns>
        private RoundInfo MakeDivisionRound(Random rand)
        {
            RoundInfo round     = new RoundInfo();
            bool      validFlag = false;

            do
            {
                round.FirstOperand  = rand.Next(DIFFICULTY_MIN, DIFFICULTY_MAX + 1);
                round.SecondOperand = rand.Next(DIFFICULTY_MIN + 1, DIFFICULTY_MAX + 1);
                if (round.FirstOperand % round.SecondOperand == 0)
                {
                    validFlag = true;
                }
            } while (!validFlag);

            round.Answer   = round.FirstOperand / round.SecondOperand;
            round.Operator = "/";

            return(round);
        }