Ejemplo n.º 1
0
        public static void AverageGuess(Random genNum)
        {
            List <int> rAvg     = new List <int>();
            List <int> bAvg     = new List <int>();
            List <int> rhAvg    = new List <int>();
            HighLow    rhapsody = new HighLow();
            Brutus     brutus   = new Brutus();
            Rando      rando    = new Rando();


            //Runns each object, including the random object, 100 times and adds the result into a seperate list.
            for (int i = 0; i < 100; i++)
            {
                int hidden = genNum.Next(1, 101);
                rhAvg.Add(rhapsody.RhapsodyGuesser(hidden, 1, 100));
                bAvg.Add(brutus.BrutusGuesser(hidden));
                //rAvg.Add(rando.RandoGuesser(hidden));
                int rand = rando.RandoGuesser(hidden);
                Console.WriteLine($"Rando guessed {rand} times");
                rAvg.Add(rand);
            }

            //Sends each list through an averager method and returns the final average
            int finalR = Average(rAvg);
            //Console.WriteLine($"Rando avg {finalR}");
            int finalRh = Average(rhAvg);
            int finalB  = Average(bAvg);

            Console.WriteLine($"{rhapsody.Name}'s average was {finalRh}\n{brutus.Name}'s average was {finalB}\n{rando.Name}'s average was {finalR}");
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            do
            {
                Console.WriteLine("Welcome to the Guesser Game!\nLet's see who the better guesser is!");
                Random genNum = new Random();
                int    hidden = genNum.Next(1, 101);
                Console.WriteLine("");
                Console.WriteLine("Rhapsody from Bohemia, is our first contestant");
                HighLow rhapsody = new HighLow();
                int     rhGuess  = rhapsody.RhapsodyGuesser(hidden, 1, 100);
                Console.WriteLine($"It took {rhapsody.Name}, {rhGuess} guesses to find the random number");
                Console.ReadLine();

                Brutus brutus = new Brutus();
                int    bGuess = brutus.BrutusGuesser(hidden);
                Console.WriteLine($"Brutus from Italy, is our second contestant");
                Console.WriteLine($"It took {brutus.Name}, {bGuess} guesses to find the random number");
                Console.ReadLine();

                Console.WriteLine("Rando from Vegas, is our third contestant.");
                Rando rando  = new Rando();
                int   rGuess = rando.RandoGuesser(hidden);
                Console.WriteLine($"It took {rando.Name}, {rGuess} guesses to find the random number");
                Console.ReadLine();

                Console.WriteLine("If we did this 100 times:");
                Console.WriteLine("Our best case scenarios for guessing are: ");
                Console.WriteLine($"{rhapsody.Name} with 1 guess\n{brutus.Name} with 1 guess\n{rando.Name} with 1 guess");
                Console.WriteLine("");
                Console.WriteLine("Our average scenarios for guessing are:");
                //This calls a method which runs each player object 100 times and averages the number of guesses
                Game.AverageGuess(genNum);
                Console.WriteLine("");
                Console.WriteLine("Our worst case scenarios are: ");
                Console.WriteLine($"{rhapsody.Name} with 7 guesses\n{brutus.Name} with 100 guess\n{rando.Name} with infinite guesses");

                Console.ReadLine();
            } while (Continue());
        }