예제 #1
0
 public void CorrectGuess()
 {
     if (!SecretWord.Contains(GuessLetters.LastOrDefault()))
     {
         Guesses--;
     }
 }
예제 #2
0
 private bool CorrectInput(char letter)
 {
     if (char.IsLetter(letter) && !GuessLetters.Contains(letter))
     {
         return(true);
     }
     return(false);
 }
예제 #3
0
        public void DisplayStatus()
        {
            Console.WriteLine("Won: {0}", Won());
            Console.WriteLine("you have {0} guesses left", Guesses);

            writeList("Available letters to guess: ", AvailableLetters);
            writeList("Guess letters: ", GuessLetters);

            var i = SecretWord.Select(letter => GuessLetters.Contains(letter) ? letter : '_');

            Console.Write(string.Join(' ', i));

            Console.WriteLine();
        }
예제 #4
0
        public void GetGuess()
        {
            char letter;

            do
            {
                Console.WriteLine();
                Console.Write("place give me a char: ");
                letter = Console.ReadKey().KeyChar;

                if (letter == Convert.ToChar(":"))
                {
                    ResetGame();
                }
            } while (!CorrectInput(letter));

            Console.WriteLine();
            letter = char.ToLower(letter);

            AvailableLetters.Remove(letter);
            GuessLetters.Add(letter);
        }
예제 #5
0
 public bool Won()
 {
     return(SecretWord.All(letter => GuessLetters.Contains(letter)));
 }