Esempio n. 1
0
        public static Dictionary <int, Batter> BatterBuilder(Dictionary <int, Batter> batters = null)
        {
            // if the dictionary passed in is not null, the stuLeng is set to the size of the dictionary, else it is set to 0
            int battersLeng;

            if (batters != null)
            {
                battersLeng = batters.Count;
            }
            else
            {
                battersLeng = 0;
            }
            string c;
            int    cParsed;

            // user provides the number of students that will be created and that input is validated
            Console.WriteLine("How many batters would you like to create? \n");
            c = Console.ReadLine();

            cParsed = Validator.CheckInts(c);

            // a new Student is created every loop and is added to the dictionary at key i
            for (int i = battersLeng; i < battersLeng + cParsed; i++)
            {
                Batter batter = new Batter();
                batters.Add(i, batter);
            }

            return(batters);
        }
Esempio n. 2
0
        public static void displayInfo(Batter batter)
        {
            // data is retrieved from the Batter object, formatted and printed
            double average  = batter.BattingAverage();
            double slugging = batter.SluggingAverage();
            string name     = batter.GetName();



            Console.WriteLine($"{name}'s averade is {average} and their slugging average is {slugging}");

            return;
        }