public void AddScoresCountTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();
            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Dragan");
            int actual = scoreBoard.Scores.Count;
            int expected = 3;

            Assert.AreEqual(expected, actual);
        }
        public void AddScoresCountTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();

            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Dragan");
            int actual   = scoreBoard.Scores.Count;
            int expected = 3;

            Assert.AreEqual(expected, actual);
        }
        public void AddSixScoresCountTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();
            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Dragan");
            scoreBoard.AddNewScore(8, "Petkan");
            scoreBoard.AddNewScore(3, "Temelko");
            scoreBoard.AddNewScore(3, "Temelko");
            List<Score> actual = scoreBoard.Scores;

            Assert.AreEqual(5, actual.Count);
        }
Exemplo n.º 4
0
    static void Main()
    {
        ScoreBoard scoreBoard = new ScoreBoard();
        besenica   game       = new besenica();

        Console.WriteLine("Welcome to “Hangman” game. Please try to guess my secret word.");
        string command = null;

        do
        {
            Console.WriteLine();
            game.PrintCurrentProgress();
            if (game.isOver())
            {
                if (game.HelpUsed)
                {
                    Console.WriteLine("You won with {0} mistake(s) but you have cheated." +
                                      " You are not allowed to enter into the scoreboard.", game.Mistackes);
                }
                else
                {
                    if (scoreBoard.GetWorstTopScore() <= game.Mistackes)
                    {
                        Console.WriteLine("You won with {0} mistake(s) but you score did not enter in the scoreboard",
                                          game.Mistackes);
                    }
                    else
                    {
                        Console.Write("Please enter your name for the top scoreboard: ");
                        string name = Console.ReadLine();
                        scoreBoard.AddNewScore(name, game.Mistackes);
                        scoreBoard.Print();
                    }
                }
                game.ReSet();
            }
            else
            {
                Console.Write("Enter your guess: ");
                command = Console.ReadLine();
                command.ToLower();
                if (command.Length == 1)
                {
                    int occuranses = game.NumberOccuranceOfLetter(command[0]);
                    if (occuranses == 0)
                    {
                        Console.WriteLine("Sorry! There are no unrevealed letters “{0}”.", command[0]);
                    }
                    else
                    {
                        Console.WriteLine("Good job! You revealed {0} letter(s).", occuranses);
                    }
                }
                else
                {
                    ExecuteCommand(command, scoreBoard, game);
                }
            }
        } while (command != "exit");
    }
        public void AddThreeScoresCountTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();
            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Dragan");
            List<Score> actual = scoreBoard.Scores;
            List<Score> expected = new List<Score>()
            {
                new Score(4, "Pesho"),
                new Score(7, "Gosho"),
                new Score(5, "Dragan")
            };

            Assert.AreEqual(expected.Count, actual.Count);
        }
        public void AddThreeScoresCountTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();

            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Dragan");
            List <Score> actual   = scoreBoard.Scores;
            List <Score> expected = new List <Score>()
            {
                new Score(4, "Pesho"),
                new Score(7, "Gosho"),
                new Score(5, "Dragan")
            };

            Assert.AreEqual(expected.Count, actual.Count);
        }
Exemplo n.º 7
0
 static void Main()
 {
     ScoreBoard scoreBoard = new ScoreBoard();
     besenica game = new besenica();
     Console.WriteLine("Welcome to “Hangman” game. Please try to guess my secret word.");
     string command = null;
     do
     {
         Console.WriteLine();
         game.PrintCurrentProgress();
         if (game.isOver())
         {
             if (game.HelpUsed)
             {
                 Console.WriteLine("You won with {0} mistake(s) but you have cheated." +
                     " You are not allowed to enter into the scoreboard.", game.Mistackes);
             }
             else
             {
                 if (scoreBoard.GetWorstTopScore() <= game.Mistackes)
                 {
                     Console.WriteLine("You won with {0} mistake(s) but you score did not enter in the scoreboard",
                         game.Mistackes);
                 }
                 else
                 {
                     Console.Write("Please enter your name for the top scoreboard: ");
                     string name = Console.ReadLine();
                     scoreBoard.AddNewScore(name, game.Mistackes);
                     scoreBoard.Print();
                 }
             }
             game.ReSet();
         }
         else
         {
             Console.Write("Enter your guess: ");
             command = Console.ReadLine();
             command.ToLower();
             if (command.Length == 1)
             {
                 int occuranses = game.NumberOccuranceOfLetter(command[0]);
                 if (occuranses == 0)
                 {
                     Console.WriteLine("Sorry! There are no unrevealed letters “{0}”.", command[0]);
                 }
                 else
                 {
                     Console.WriteLine("Good job! You revealed {0} letter(s).", occuranses);
                 }
             }
             else
             {
                 ExecuteCommand(command, scoreBoard, game);
             }
         }
     } while (command != "exit");
 }
        public void AddThreeDifferentScoresTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();
            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Drago");
            List<Score> actual = scoreBoard.Scores;
            List<Score> expected = new List<Score>()
            {
                new Score(4, "Pesho"),
                new Score(7, "Gosho"),
                new Score(5, "Dragan")
            };

            expected.Sort();

            CollectionAssert.AreNotEqual(expected, actual);
        }
Exemplo n.º 9
0
        public void PlayerCommandTopTest()
        {
            PlayerPosition startPosition = new PlayerPosition(3, 3);

            string[] rawData = new string[Labyrinth.LabyrinthSize]
            {
                "XXXXXXX",
                "X-X---X",
                "X---X-X",
                "X--*--X",
                "X-X----",
                "X-----X",
                "XXXXXXX"
            };

            Cell[,] board = LabyrinthDataFromStringArray(rawData);

            Labyrinth labyrinth = new Labyrinth(startPosition, board);

            var privateObject = new PrivateObject(labyrinth);

            ScoreBoard scoreBoard = new ScoreBoard();

            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Dragan");
            labyrinth.ScoreBoard = scoreBoard;
            string actual   = labyrinth.ScoreBoard.ToString();
            string expected = @"
Top 5:

1. Pesho ---> 4 moves
2. Dragan ---> 5 moves
3. Gosho ---> 7 moves


";
            int    x        = 3;
            int    y        = 3;

            privateObject.Invoke("ProcessMove", "top", x, y);

            Assert.AreEqual(expected, actual);
        }
        public void AddThreeDifferentScoresTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();

            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Drago");
            List <Score> actual   = scoreBoard.Scores;
            List <Score> expected = new List <Score>()
            {
                new Score(4, "Pesho"),
                new Score(7, "Gosho"),
                new Score(5, "Dragan")
            };

            expected.Sort();

            CollectionAssert.AreNotEqual(expected, actual);
        }
        public void ToStringTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();

            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Dragan");
            string actual   = scoreBoard.ToString();
            string expected = @"
Top 5:

1. Pesho ---> 4 moves
2. Dragan ---> 5 moves
3. Gosho ---> 7 moves


";

            Assert.AreEqual(expected, actual);
        }
        public void AddSixScoresCountTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();

            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Dragan");
            scoreBoard.AddNewScore(8, "Petkan");
            scoreBoard.AddNewScore(3, "Temelko");
            scoreBoard.AddNewScore(3, "Temelko");
            List <Score> actual = scoreBoard.Scores;

            Assert.AreEqual(5, actual.Count);
        }
        public void ToStringTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();
            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Dragan");
            string actual = scoreBoard.ToString();
            string expected = @"
Top 5:

1. Pesho ---> 4 moves
2. Dragan ---> 5 moves
3. Gosho ---> 7 moves


";

            Assert.AreEqual(expected, actual);
        }
        public void PlayerCommandTopTest()
        {
            PlayerPosition startPosition = new PlayerPosition(3, 3);

            string[] rawData = new string[Labyrinth.LabyrinthSize]
            {
                "XXXXXXX",
                "X-X---X",
                "X---X-X",
                "X--*--X",
                "X-X----",
                "X-----X",
                "XXXXXXX"
            };

            Cell[,] board = LabyrinthDataFromStringArray(rawData);

            Labyrinth labyrinth = new Labyrinth(startPosition, board);

            var privateObject = new PrivateObject(labyrinth);

            ScoreBoard scoreBoard = new ScoreBoard();
            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Dragan");
            labyrinth.ScoreBoard = scoreBoard;
            string actual = labyrinth.ScoreBoard.ToString();
            string expected = @"
Top 5:

1. Pesho ---> 4 moves
2. Dragan ---> 5 moves
3. Gosho ---> 7 moves


";
            int x = 3;
            int y = 3;
            privateObject.Invoke("ProcessMove", "top", x, y);

            Assert.AreEqual(expected, actual);
        }