Exemple #1
0
        public 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);
        }
Exemple #2
0
        public DiaryStatistics ComputeStats()
        {
            // chcemy, żeby metoda zwracałą obiekt DiaryStatistics
            DiaryStatistics stats = new DiaryStatistics();

            var sum = 0f;

            foreach (var rating in Ratings)
            {
                sum += rating;
            }
            stats.AverageGrade = sum / Ratings.Count();
            stats.MaxGrade     = Ratings.Max();
            stats.MinGrade     = Ratings.Min();

            return(stats);
        }
Exemple #3
0
        ///<summary>
        ///Wyliczenie statystyk dzienniczka
        ///</summary>>
        public DiaryStatistics ComputeStatistics()
        {
            DiaryStatistics stats = new DiaryStatistics();

            float sum = 0f;                 //zmienne pomocnicza

            foreach (var rating in ratings) //pętla sumująca elementy listy
            {
                sum += rating;
            }

            stats.AverageGrade = sum / ratings.Count(); //wyliczenie średniej

            stats.MaxGrade = ratings.Max();             //najwyższa ocena

            stats.MinGrade = ratings.Min();             //najniższa ocena

            return(stats);
        }
Exemple #4
0
        //static void GiveName(ref Diary diary)
        //{
        //    diary = new Diary();
        //    diary.Name = "Nowy Dzienniczek Marcina";
        //}

        //static int IncrementNumber(int number)
        //{
        //    number = 42;
        //    return number;
        //}
        static void Main(string[] args)
        //{
        //    //PassByValueAndRef();

        //    // Immutable();
        //    Arrays();
        //}

        //private static void Arrays()
        //{
        //    float[] ratings;
        //    ratings = new float[5];

        //    AddRatings(ratings);


        //    foreach (var rating in ratings)
        //    {
        //        Console.WriteLine(rating);
        //    }
        //}

        //private static void AddRatings(float[] ratings)
        //{
        //    if (ratings.Length >= 4)
        //    {
        //        ratings[0] = 4.2f;
        //        ratings[1] = 6.7f;
        //        ratings[2] = 3f;
        //        ratings[3] = 8.5f;
        //        ratings[4] = 4.4f;
        //    }
        //}

        //private static void Immutable()
        //{
        //    string name = "   Marcin    ";
        //    name = name.Trim();
        //    Console.WriteLine(name);

        //    DateTime date = new DateTime(2015, 3, 10);
        //    date = date.AddHours(48);
        //    Console.WriteLine(date);
        //}


        //string name1 = "  Marcin  ";
        //string name2 = "marcin";

        //bool areEqual = name1.Equals(name2, StringComparison.CurrentCultureIgnoreCase);
        //Console.WriteLine(areEqual);
        {
            Diary diary = new Diary();

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

            //Diary diary2 = new Diary();
            //Diary diary3 = new Diary();
            //Diary diary4 = new Diary();
            //Diary diary5 = new Diary();
            //Diary diary6 = new Diary();
            //Console.WriteLine(Diary.Count);

            DiaryStatistics stats = diary.ComputeStatistics();

            Console.WriteLine("Średnia Twoich ocen to: " + stats.AverageGrade);
            Console.WriteLine("Najwyższa ocena to: " + stats.MaxGrade);
            Console.WriteLine("Najniższa ocena to: " + stats.MinGrade);
            Console.ReadKey();

            Diary diary2 = new Diary();

            diary2.AddRating(5);
            diary2.AddRating(2.5f);
            diary2.AddRating(3.7f);
            diary2.AddRating(4.2f);
            diary2.AddRating(7.6f);

            stats = diary2.ComputeStatistics();

            Console.WriteLine("Średnia Twoich ocen to: " + stats.AverageGrade);
            Console.WriteLine("Najwyższa ocena to: " + stats.MaxGrade);
            Console.WriteLine("Najniższa ocena to: " + stats.MinGrade);
            Console.ReadKey();

            //SpeechSynthesizer synt = new SpeechSynthesizer();
            //synt.Speak("Cześć Beatka. Jak się czujesz?. Czego tu");

            //float avg = diary.CalculateAverage();
            //float max = diary.GiveMaxRating();
            //float min = diary.GiveMinRating();
        }