Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Diary diary = new Members.Diary();

            diary.AddNewRating(9.9f);
            diary.AddNewRating(7.5f);
            diary.AddNewRating(8f);

            DiaryStats stats = diary.ComputeStats();

            Console.WriteLine(stats.maxGrade);
            Console.WriteLine(stats.minGrade);
            Console.WriteLine(stats.avgGrade);
        }
Ejemplo n.º 2
0
        public DiaryStats ComputeStats()
        {
            DiaryStats stats = new DiaryStats();

            float sum = 0;

            foreach (var rating in ratings)
            {
                sum += rating;
            }

            stats.avgGrade = sum / ratings.Count;
            stats.maxGrade = ratings.Max();
            stats.minGrade = ratings.Min();

            return(stats);
        }