41 lines
958 B
C#

using System;
using System.Collections.Generic;
namespace GradeBook
{
public class Book
{
private List<double> grades;
public string Name;
public Book(string name)
{
Name = name;
grades = new List<double>();
}
public void AddGrade(double grade)
{
this.grades.Add(grade);
}
public Statistics GetStatistics()
{
var result = new Statistics();
result.Average = 0.0;
result.highGrade = double.MinValue;
result.lowGrade = double.MaxValue;
foreach (var grade in this.grades)
{
result.lowGrade = Math.Min(grade, result.lowGrade);
result.highGrade = Math.Max(grade, result.highGrade);
result.Average += grade;
}
result.Average /= grades.Count;
return result;
}
}
}