public ActionResult Update(string letter)
        {
            // Use the word that was just created
            MysteryWord playerWord = MysteryWord.FindRandom(MysteryWord.randomId);
            bool        duplicate  = playerWord.AlreadyGuessed(letter);

            if (duplicate)
            {
                Console.WriteLine("Already guessed this letter. Try a different letter.");
            }
            else
            {
                playerWord.AddLetter(letter);
                bool isMatch = playerWord.CheckLetter();
                if (isMatch)
                {
                    bool win = playerWord.Win();
                }
                else
                {
                    playerWord.Score++;
                }
                bool lose = playerWord.isGameOver();
                if (lose)
                {
                    Console.WriteLine("You lose");
                }
            }
            return(View(playerWord));
        }
Exemplo n.º 2
0
        public ActionResult Update(string letter)
        {
            // Use the word that was just created
            MysteryWord playerWord = MysteryWord.Find(1);
            bool        duplicate  = playerWord.AlreadyGuessed(letter);

            if (duplicate)
            {
                ViewBag.Message = string.Format("Hello {0}.\\nCurrent Date and Time: {1}", letter, DateTime.Now.ToString());
                Console.WriteLine("Already guessed this letter. Try a different letter.");
            }
            else
            {
                playerWord.AddLetter(letter);
                bool isMatch = playerWord.CheckLetter();
                if (isMatch)
                {
                    bool win = playerWord.Win();
                    // For all blanks that are that letter, fill them in
                }
                else
                {
                    playerWord.Score++;
                }
                bool lose = playerWord.isGameOver();
                if (lose)
                {
                    Console.WriteLine("You lose");
                }
            }
            return(View(playerWord));
        }
Exemplo n.º 3
0
        public void CheckLetter_ReturnFalse_Bool()
        {
            // Arrange a mysteryword instance and a letter instance
            MysteryWord newWord   = new MysteryWord("Dollar tree");
            Letter      newLetter = new Letter("z");
            // Get the actual result
            bool result = newWord.CheckLetter();

            //Assert
            Assert.AreEqual(false, result);
        }
Exemplo n.º 4
0
        public void CheckLetter_ReturnTrue_Bool()
        {
            // Arrange a mysteryWord instance and a letter instance
            MysteryWord newWord = new MysteryWord("Dollar Tree");

            newWord.AddLetter("R");
            // Get the result from the method
            bool result = newWord.CheckLetter();

            // Assert
            Assert.AreEqual(true, result);
        }