Exemple #1
0
        public override GradeStatististics ComputeStatistics()
        {
            Console.WriteLine("Gradebook::ComputeStatistics");
            GradeStatististics stats = new GradeStatististics();

            //stats.HighestGrade = 0;

            float sum = 0;

            foreach (float grade in grades)
            {
                //if (grade > stats.HighestGrade)
                //{
                //    stats.HighestGrade = grade;

                //}
                stats.HighestGrade = Math.Max(grade, stats.HighestGrade);
                //stats.LowestGrade = Math.Min(grade, stats.HighestGrade);
                stats.LowestGrade = Math.Min(grade, stats.LowestGrade);

                sum = sum + grade;  //lub sum += grade
            }

            stats.AverageGrade = sum / grades.Count;

            return(stats);
        }
Exemple #2
0
        private static void WriteResults(IGradeTracker book)
        {
            GradeStatististics stats = book.ComputeStatistics();

            foreach (float grade in book)
            {
                Console.WriteLine(grade);
            }

            Console.WriteLine(book.Name);
            WriteResult("Average", stats.AverageGrade);
            WriteResult("Highest", stats.HighestGrade);
            WriteResult("Lowest", stats.LowestGrade);
            WriteResult("Grade", stats.LetterGrade);
            WriteResult("My opinion", stats.Description);
        }