예제 #1
0
        //5/3/19: LimitSolver
        //static float LimitSolver(float[] numerator, float[] denominator)
        //{
        //    if (numerator.Contains<int>(0))
        //        throw Exception("Wrong input");
        //    if (denominator.Contains<int>(0))
        //        throw Exception("Wrong input");
        //    if (numerator.Length > denominator.Length)
        //        return float.MaxValue;
        //    else if (numerator.Length <  denominator.Length)
        //        return 0;

        //    return 0;
        //}
        //Arithmetic game
        //totalQns: questions asked per round
        //digits: digits of both operands
        public static void Game(int totalQns, int maxDigits, int minVal, int maxVal)
        {
            var    quit   = false;
            var    score  = 0;
            string opType = "";

            ArithmeticLoop al = new ArithmeticLoop(PlayRound);

            while (quit == false)
            {
                //Console.WriteLine("1 Decimal, 2 Decimal, or Integers?");
                //string useDecimal = Console.ReadLine();
                Console.WriteLine("Mulitply, Divide, Add\nSerial Add'n, Serial Multiplication\n" +
                                  "Subtract, Squares(2), Modulus\nFactor, Percentage\nLog, Power(pow)");
                opType = Console.ReadLine();
                Stopwatch time10kOperations = Stopwatch.StartNew();
                score += ScoredRounds(al, totalQns, maxDigits, minVal, maxVal, opType, time10kOperations);
                time10kOperations.Reset();



                Console.WriteLine("Continue (y/n)?");
                quit = Console.ReadLine() == "y" ? false : true;
            }


            //import phonetic.txt
            //random number and then append to text file
        }
예제 #2
0
        public static int Play1RndArithmeticGame(int totalQns, int maxDigits, int minVal, int maxVal)
        {
            var    score  = 0;
            string opType = "";

            ArithmeticLoop al = new ArithmeticLoop(PlayRound);

            var types = new String[] { "a", "m", "s", "sa" };

            opType = types[new Random().Next(0, types.Length - 1)];
            Stopwatch time10kOperations = Stopwatch.StartNew();

            score += al(totalQns, maxDigits, minVal, maxVal, opType, time10kOperations);
            time10kOperations.Reset();
            Console.WriteLine("{0} points", score);

            return(score);
        }
예제 #3
0
        public static int ScoredRounds(ArithmeticLoop ld, int totalQns, int maxDigits, int minVal, int maxVal, string opType, Stopwatch w)
        {
            int pts = 0;

            do
            {
                pts += ld(totalQns, maxDigits, minVal, maxVal, opType, w);
                Console.WriteLine("Continue?");
                var foo = Console.ReadLine();

                if (foo == "n" || foo == "N")
                {
                    break;
                }
                Console.Clear();
            } while (true);
            return(pts);
        }