コード例 #1
0
ファイル: GradeBook.cs プロジェクト: telangn/OOP-in-Csharp
        public override GradeStatistics ComputeStatistics()
        {
            GradeStatistics stats = new GradeStatistics();

            float sum = 0;

            foreach (float grade in grades)
            {
                stats.HighestGrade = Math.Max(grade, stats.HighestGrade);
                stats.LowestGrade  = Math.Min(grade, stats.LowestGrade);
                sum += grade;
            }
            stats.AverageGrade = sum / grades.Count;

            return(stats);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: telangn/OOP-in-Csharp
        private static void WriteResults(IGradeTracker book1)
        {
            GradeStatistics book1stats = book1.ComputeStatistics();

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


            WriteResult("Name", book1.Name);
            WriteResult("Average", book1stats.AverageGrade);
            WriteResult("Highest Grade", book1stats.HighestGrade);
            WriteResult("Lowest Grade", book1stats.LowestGrade);
            WriteResult("Grade", book1stats.LetterGrade);
            WriteResult("Description", book1stats.Description);
        }