Пример #1
0
        public static decimal TryDivisionRecursive()
        {
            var result = 0M;

            var questions = new string[] {
                "Introduzca el primer número: ",
                "Introduzca el segundo número: "
            };

            var answer1 = ConsoleAppPrintUtil.PrintQuestionWithStringAnswer(questions[0]);

            var answer2 = ConsoleAppPrintUtil.PrintQuestionWithStringAnswer(questions[1]);

            var number1 = answer1 == string.Empty ? null : answer1;

            var number2 = answer2 == string.Empty ? null : answer2;

            result = ConsoleAppPrintUtil.PrintDivision(number1, number2);

            if (result == 0M)
            {
                TryDivisionRecursive();
            }

            return(result);
        }
Пример #2
0
        public static ArrayList GetArrayListOfNumbersLessThan(int countOfNumbers, string text, int lessThan)
        {
            var numbers = new ArrayList();

            int index = 0;

            while (index < countOfNumbers)
            {
                var number = ConsoleAppPrintUtil.PrintQuestionWithIntAnswerLessThanRecursive($"{text} {index + 1}:", lessThan);
                numbers.Add(number);
                index++;
            }

            return(numbers);
        }
Пример #3
0
        public static string ShowExerciseOption(string answerOfQuestion,
                                                List <int> exerciseNumbers, List <string> correctAnswerOfExerciseOption)
        {
            if (answerOfQuestion != string.Empty)
            {
                return(answerOfQuestion);
            }

            PrintExerciseOptions(exerciseNumbers);

            answerOfQuestion = Console.ReadLine();

            if (!correctAnswerOfExerciseOption.Exists(ca => ca.Equals(answerOfQuestion)))
            {
                ConsoleAppPrintUtil.PrintTextWithLineSeparator("Lo siento pero la respuesta debe ser " + String.Join("/", exerciseNumbers) + " o E");
                answerOfQuestion = string.Empty;
                answerOfQuestion = ShowExerciseOption(answerOfQuestion, exerciseNumbers, correctAnswerOfExerciseOption);
            }

            return(answerOfQuestion);
        }