Exemplo n.º 1
0
        private int GetNumberInput()
        {
            Console.WriteLine("Enter any number");

            var inputNumber = Console.ReadLine();

            if (UserInputValidation.NumberNegativeOrInvalid(inputNumber))
            {
                Console.WriteLine("Please enter a positive number, try again:");
                GetNumberInput();
            }
            return(int.Parse(inputNumber));
        }
Exemplo n.º 2
0
        public string Play()
        {
            Console.WriteLine("Pick a number, any number and I will sum all the numbers from 1 to N!");

            var inputNumber = Console.ReadLine();

            if (UserInputValidation.NumberNegativeOrInvalid(inputNumber))
            {
                Console.WriteLine("Please enter a positive number, try again:");
                Play();
            }

            return(OperationFromOneToN.Sum(int.Parse(inputNumber)));
        }
Exemplo n.º 3
0
        public string Play()
        {
            Console.WriteLine("Enter a number and I will return the sum of all multiples of 3 or 5 from 1 to N");

            var inputNumber = Console.ReadLine();

            if (UserInputValidation.NumberNegativeOrInvalid(inputNumber))
            {
                Console.WriteLine("Please enter a positive number, try again:");
                Play();
            }

            return(SumNumbersIfMultiplesOf3Or5(int.Parse(inputNumber)));
        }