public void CorrectGuess() { if (!SecretWord.Contains(GuessLetters.LastOrDefault())) { Guesses--; } }
private bool CorrectInput(char letter) { if (char.IsLetter(letter) && !GuessLetters.Contains(letter)) { return(true); } return(false); }
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(); }
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); }
public bool Won() { return(SecretWord.All(letter => GuessLetters.Contains(letter))); }