public void ComputesLowestRate()
        {
            RatingBook book = new RatingBook();

            book.AddRating(19);
            book.AddRating(89);

            RatingStats result = book.CalculateStats();

            Assert.AreEqual(19, result.LowestGrade);
        }
        public void ComputesAvegareGrade()
        {
            RatingBook book = new RatingBook();

            book.AddRating(56);
            book.AddRating(89.5f);
            book.AddRating(23);

            RatingStats result = book.CalculateStats();

            // Assertion made for float numbers
            Assert.AreEqual(56.16, result.AverageGrade, 0.01);
        }
        public void ComputesHighestRate()
        {
            // Establish a reference from Tests Project to the main Project
            // Set the protection level right so you can create a RatingBook object
            RatingBook book = new RatingBook();

            book.AddRating(50);
            book.AddRating(70);

            RatingStats result = book.CalculateStats();

            Assert.AreEqual(70, result.HighestGrade);
            // What if someone changes the code inside CalculateStats. The developer will know cause the test will fail.
        }
Esempio n. 4
0
        private static void Main()
        {
            string command = string.Empty;

            char[,] field = CreatePlayingFild();
            char[,] bombs = PuttingBombs();
            int  counter = 0;
            bool explode = false;
            List <RatingStats> champoins = new List <RatingStats>(6);
            int       row     = 0;
            int       column  = 0;
            bool      flag    = true;
            const int maximum = 35;
            bool      flagTwo = false;

            do
            {
                if (flag)
                {
                    Console.WriteLine("Lets play Minesweeper, try your luck" + " Comand 'top' shows the score, 'restart' begins new game, 'exit' exits!");
                    Dumpp(field);
                    flag = false;
                }

                Console.Write("Gving row and colon");
                command = Console.ReadLine().Trim();
                if (command.Length >= 3)
                {
                    if (int.TryParse(command[0].ToString(), out row) && int.TryParse(command[2].ToString(), out column) &&
                        row <= field.GetLength(0) && column <= field.GetLength(1))
                    {
                        command = "turn";
                    }
                }

                switch (command)
                {
                case "top":
                    Raiting(champoins);
                    break;

                case "restart":
                    field = CreatePlayingFild();
                    bombs = PuttingBombs();
                    Dumpp(field);
                    explode = false;
                    flag    = false;
                    break;

                case "exit":
                    Console.WriteLine("bye, bye, bye");
                    break;

                case "turn":
                    if (bombs[row, column] != '*')
                    {
                        if (bombs[row, column] == '-')
                        {
                            SilenceTurn(field, bombs, row, column);
                            counter++;
                        }

                        if (maximum == counter)
                        {
                            flagTwo = true;
                        }
                        else
                        {
                            Dumpp(field);
                        }
                    }
                    else
                    {
                        explode = true;
                    }

                    break;

                default:
                    Console.WriteLine("\nMistake invalid comand\n");
                    break;
                }

                if (explode)
                {
                    Dumpp(bombs);
                    Console.Write("\nDies with hero with {0} score. " + "Give your nickname: ", counter);
                    string      nickName   = Console.ReadLine();
                    RatingStats charackter = new RatingStats(nickName, counter);
                    if (champoins.Count < 5)
                    {
                        champoins.Add(charackter);
                    }
                    else
                    {
                        for (int i = 0; i < champoins.Count; i++)
                        {
                            if (champoins[i].Score < charackter.Score)
                            {
                                champoins.Insert(i, charackter);
                                champoins.RemoveAt(champoins.Count - 1);
                                break;
                            }
                        }
                    }

                    champoins.Sort((RatingStats firstRaiting, RatingStats secondRaiting) => secondRaiting.Player.CompareTo(firstRaiting.Player));
                    champoins.Sort((RatingStats firstRaiting, RatingStats secondRaiting) => secondRaiting.Score.CompareTo(firstRaiting.Score));
                    Raiting(champoins);

                    field   = CreatePlayingFild();
                    bombs   = PuttingBombs();
                    counter = 0;
                    explode = false;
                    flag    = true;
                }

                if (flagTwo)
                {
                    Console.WriteLine("Good 35 points without hitting a mine");
                    Dumpp(bombs);
                    Console.WriteLine("What is your name ");
                    string      name   = Console.ReadLine();
                    RatingStats points = new RatingStats(name, counter);
                    champoins.Add(points);
                    Raiting(champoins);
                    field   = CreatePlayingFild();
                    bombs   = PuttingBombs();
                    counter = 0;
                    flagTwo = false;
                    flag    = true;
                }
            }while (command != "exit");
            Console.WriteLine("Made in Bulgaria");
            Console.WriteLine("Come onnnnnnnn");
            Console.Read();
        }