示例#1
0
        internal DiaryStatistics ComputeStatistics()
        {
            DiaryStatistics stats = new DiaryStatistics();

            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);
        }
示例#2
0
        static void Main(string[] args)
        {
            Diary diary = new Diary(); // declaration first class // new creat instation of diary

            diary.AddRating(5);
            diary.AddRating(8.5f);
            diary.AddRating(4.7f);

            DiaryStatistics stats = diary.ComputeStatistics();

            //var avg = stats.AverageGrade;

            Console.WriteLine("Average Value:" + stats.AverageGrade);
            Console.WriteLine("Average Value Max:" + stats.MaxGrade);
            Console.WriteLine("Average Value Min:" + stats.MinGrade);

            Console.ReadKey();
        }