//public string SecretWord { get; } public GuessResult Guess(char guess) { //_guesses.Add(guess); //throw new NotImplementedException(); if (guess == 'Q') { return(GuessResult.QuitPlay); } if (!Evaluate.LegalKey(guess)) { return(GuessResult.InvalidGuess); } if (Evaluate.KeyExists(guess, _misses, _scoreboard)) { return(GuessResult.AlreadyGuessed); } if (Evaluate.HitOrMiss(guess, _secretword, _scoreboard)) { return(GuessResult.CorrectGuess); } Evaluate.AddCharValue(guess, _misses); return(GuessResult.IncorrectGuess); }
public static char ReadChar(int number) // OO: Nice method, just think about the name of the method { char key; do { Console.Write($"Next one to try ({number}) > "); key = Console.ReadKey().KeyChar; if (key != 'Q') // Quit character. // OO: Detail, if you create a variable named QuitCharacter, then you don't need the comment { //Console.WriteLine(""); key = (key.ToString().ToUpper())[0]; //if (!((key >= 'A' && key <= 'Z') || key == 'Æ' || key == 'Ø' || key == 'Å')) if (!Evaluate.LegalKey(key)) { Console.WriteLine($" Illegal input '{key}'."); key = ' '; } } } while (key == ' '); return(key); }