public static void ShowStatistic(DiaryStatistic stats) { SpeechSynthesizer synth = new SpeechSynthesizer(); synth.Speak("Who is the most beautiful girl in the world? Anna"); //synth.Speak("Average grade: " + stats.AverageGrade); Console.WriteLine("Średnia ocena: " + stats.AverageGrade); Console.WriteLine("Najmniejsza ocena: " + stats.MinGrade); Console.WriteLine("Najwieksza ocena: " + stats.MaxGrade); }
//Metody // Computes statitistic (average, max and min grade) for given student internal DiaryStatistic ComputeStatistic() { DiaryStatistic stats = new DiaryStatistic(); float sum = 0f; foreach (var rating in ratings) { sum += rating; } stats.AverageGrade = sum / ratings.Count(); stats.MaxGrade = ratings.Max(); stats.MinGrade = ratings.Min(); return(stats); }
static void Main(string[] args) { Diary student1 = new Diary(); student1.AddName(); Diary.AskForRatings(student1); DiaryStatistic stats = student1.ComputeStatistic(); DiaryStatistic.ShowStatistic(stats); Diary student2 = new Diary(); student2.AddName(); Diary.AskForRatings(student2); stats = student2.ComputeStatistic(); DiaryStatistic.ShowStatistic(stats); }
public static void ShowStatistic(DiaryStatistic stats) { Console.WriteLine("Średnia ocena: " + stats.AverageGrade); Console.WriteLine("Najmniejsza ocena: " + stats.MinGrade); Console.WriteLine("Najwieksza ocena: " + stats.MaxGrade); }