public bool Play() { var gameRound = new GameRound(GameAnswers.GenerateRandomAnswer()); Console.WriteLine($"{Environment.NewLine}Here We Go! Take your best guess"); for (int i = 0; i < NUMBER_OF_CHANCES; i++) { if (i > 0) { Console.Write($"{Environment.NewLine}Guess #{i + 1}: "); } var guess = Console.ReadLine(); bool isValidGuess = gameRound.TryToParseGuess(guess, out int[] result); if (isValidGuess) { var isSuccess = CheckGuessOutcome(gameRound, result); if (isSuccess) { return(true); } } else { HandleInvalidGuess(); } } return(false); }
private bool CheckGuessOutcome(GameRound gameRound, int[] guess) { var outcome = gameRound.CheckAnswer(guess); if (outcome.Equals(GameAnswers.CorrectGuess)) { Console.WriteLine("Congratulations you guessed the correct answer!"); return(true); } else { Console.WriteLine(outcome); return(false); } }