Пример #1
0
        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);
        }
Пример #2
0
 public GameRound(int[] answer = null)
 {
     _answer = (answer ?? GameAnswers.GenerateRandomAnswer());
     Debug.WriteLine(string.Join("-", _answer));
 }