Esempio n. 1
0
        public override Statistcs GetStatistics()
        {
            var result = new Statistcs();

            for (var index = 0; index < grades.Count; index++)
            {
                result.Add(grades[index]);
            }

            return(result);
        }
        static void Main(string[] args)
        {
            IBook book = new DiskBook("Daniel's Grade Book");

            EnterGrades(book);

            Statistcs statistcs = book.GetStatistics();

            Console.WriteLine($"The lowest grade is {statistcs.Low}");
            Console.WriteLine($"The average grade is {statistcs.Average:N1}");
            Console.WriteLine($"The highest grade is {statistcs.High}");
            Console.WriteLine($"The Letter grade is {statistcs.Letter}");
        }
Esempio n. 3
0
        public override Statistcs GetStatistics()
        // we use the class identifier Statistics. So this is a public method named GetStatistics, and its return type,
        // that is the type of object is going to return, is Statitics.
        {
            var result = new Statistcs();

            // var arr = new List<double>(){};

            for (var index = 0; index < grades.Count; index++)
            {
                result.Add(grades[index]);
            }
            return(result);
        }
Esempio n. 4
0
        public override Statistcs GetStatistics()
        {
            var result = new Statistcs();

            using (var reader = File.OpenText($"{Name}.txt"))
            {
                var line = reader.ReadLine();
                while (line != null)
                {
                    var number = double.Parse(line);
                    result.Add(number);
                    line = reader.ReadLine();
                }
            }

            return(result);
        }