Exemplo n.º 1
0
        /// <summary>
        /// Gets the number of blacks and whites for the given code from the
        /// user.
        /// </summary>
        public static (int blacks, int whites) GetBlacksWhites(Code code)
        {
            while (true)
            {
                View.PromptBlacksWhites(code);

                var input = Console.ReadLine();
                if (input is null)
                {
                    Environment.Exit(0);
                }

                var parts = input.Split(',');

                if (parts.Length != 2)
                {
                    View.PromptTwoValues();
                }
                else
                if (!Int32.TryParse(parts[0], out var blacks) || !Int32.TryParse(parts[1], out var whites))
                {
                    View.PromptValidInteger();
                }
                else
                {
                    return(blacks, whites);
                }
            }
        }