Beispiel #1
0
        private static void Exercise4()
        {
            ConsoleAppPrintUtil.PrintTextWithLineSeparator("Ejercicio 4:", useReadLine: false);

            ConsoleAppPrintUtil.PrintText("Complete los datos del alumno:", useConsoleClear: false);

            var questions = new string[] {
                "¿Cuáles son tus apellidos?",
                "¿Qué edad tienes?",
                "¿Cuál es tu nombre?",
                "¿Cuál es la nota del examen?",
                "¿Cuál es su género?"
            };

            var student = new Student
            {
                Name = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[2]),

                LastName = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[0]),

                Age = ConsoleAppPrintUtil.PrintQuestionWithIntAnswerLessThanRecursive(questions[1], 150),

                ExaminationNote = ConsoleAppPrintUtil.PrintQuestionWithIntAnswerLessThanRecursive(questions[3], 10),

                Sex = ConsoleAppPrintUtil.PrintQuestionWithCharAnswerRecursive(questions[4], correctAnswers: new string[] { "H", "M" })
            };

            ConsoleAppPrintUtil.PrintText($"Los datos del alumno son > {student}.");
        }
Beispiel #2
0
        private static void Exercise1()
        {
            ConsoleAppPrintUtil.PrintTextWithLineSeparator("Ejercicio 1:", useReadLine: false);

            ConsoleAppPrintUtil.PrintText("Complete los datos restantes del alumno 1:", useConsoleClear: false);

            var questions = new string[] {
                "¿Cuáles son tus apellidos?",
                "¿Qué edad tienes?",
                "¿Cuál es tu nombre?"
            };

            var student1 = GetStudentWithoutName(questions);

            student1.Name = "Alumno 1";

            ConsoleAppPrintUtil.PrintText($"Los datos del alumno 1 son > {student1}.");

            ConsoleAppPrintUtil.PrintText("Complete los datos del alumno 2:");

            var student2 = GetStudentWithoutName(questions);

            student2.Name = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[2]);

            ConsoleAppPrintUtil.PrintText($"Los datos del alumno 2 son > {student2}.");
        }
Beispiel #3
0
        private static void Exercise6()
        {
            ConsoleAppPrintUtil.PrintTextWithLineSeparator("Ejercicio 6:");

            const string text1  = "Escriba una cadena para invertirla:";
            var          answer = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(text1);

            string answerReverse = ConsoleAppUtil.Reverse(answer);

            ConsoleAppPrintUtil.PrintText($"Cadena invertida: {answerReverse}");
        }
Beispiel #4
0
        private static Student GetStudentWithoutName(string[] questions)
        {
            var student = new Student
            {
                LastName = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[0]),

                Age = ConsoleAppPrintUtil.PrintQuestionWithIntAnswerLessThanRecursive(questions[1], 150)
            };

            return(student);
        }
Beispiel #5
0
        private static void Exercise7()
        {
            ConsoleAppPrintUtil.PrintTextWithLineSeparator("Ejercicio 7:");

            const string text1        = "Path del fichero de lectura:";
            var          fileFromPath = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(text1);

            const string text2      = "Path del fichero de escritura:";
            var          fileToPath = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(text2);

            var transferData = ConsoleAppUtil.TransferDataFromFile(fileFromPath, fileToPath);

            Exercise7PrintText(transferData);
        }
Beispiel #6
0
        private static void Exercise3()
        {
            ConsoleAppPrintUtil.PrintTextWithLineSeparator("Ejercicio 3:");

            var temperature = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive("Introduce una temperatura en grados Fahrenheit: ");

            try
            {
                var temperatureNumber = int.Parse(temperature);
                ConsoleAppPrintUtil.PrintText($"La temperatura en grados celsius es de: {temperatureNumber}");
            }
            catch (Exception ex)
            {
                ConsoleAppPrintUtil.PrintText(ex.Message, useConsoleClear: false, useReadLine: false);
                ConsoleAppPrintUtil.PrintText(ex.StackTrace, useConsoleClear: false);
            }
        }
Beispiel #7
0
        private static void Exercise5()
        {
            ConsoleAppPrintUtil.PrintTextWithLineSeparator("Ejercicio 5:", useReadLine: false);

            ConsoleAppPrintUtil.PrintText("Complete los datos del alumno:", useConsoleClear: false);

            var questions = new string[] {
                "¿Cuáles son tus apellidos?",
                "¿Qué edad tienes?",
                "¿Cuál es tu nombre?",
                "¿Cuál es la nota del examen?",
                "¿Cuál es su género?",
                "¿Cuál es el nombre de la Asignatura?",
                "¿Cuál es el área de la Asignatura?"
            };

            var student = new Student
            {
                Name = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[2]),

                LastName = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[0]),

                Age = ConsoleAppPrintUtil.PrintQuestionWithIntAnswerLessThanRecursive(questions[1], 150),

                ExaminationNote = ConsoleAppPrintUtil.PrintQuestionWithIntAnswerLessThanRecursive(questions[3], 10),

                Sex = ConsoleAppPrintUtil.PrintQuestionWithCharAnswerRecursive(questions[4], correctAnswers: new string[] { "H", "M" })
            };

            ConsoleAppPrintUtil.PrintText("Complete los datos de las 10 asignaturas del alumno:");

            do
            {
                ConsoleAppPrintUtil.PrintText($"Complete los datos de la Asignatura {student.Subjects.Count() + 1}");

                var asignatura = new Subject()
                {
                    Name = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[5]),
                    Area = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[6])
                };
                student.Subjects.Add(asignatura);
            } while (student.Subjects.Count() < 10);

            ConsoleAppPrintUtil.PrintText(GetExercise5Text(student));
        }
Beispiel #8
0
        private static void Exercise1()
        {
            ConsoleAppPrintUtil.PrintTextWithLineSeparator("Ejercicio 1:");

            var questions = new string[] {
                "Introduzca su nombre:",
                "Introduzca sus apellidos:",
                "Introduzca su edad:"
            };

            var name = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[0]);

            var lastName = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[1]);

            var age = ConsoleAppPrintUtil.PrintQuestionWithIntAnswerLessThanRecursive(questions[2], 150);

            ConsoleAppPrintUtil.PrintText(GetExercise1Text(name, lastName, age));
        }
Beispiel #9
0
        private static void Exercise4()
        {
            ConsoleAppPrintUtil.PrintTextWithLineSeparator("Ejercicio 4:");

            var questions = new string[] {
                "¿Cómo te llamas?",
                "¿Cuántas horas has trabajado?",
                "¿Qué precio cobras por hora?"
            };

            var name = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[0]);

            var hoursWorked = ConsoleAppPrintUtil.PrintQuestionWithIntAnswerRecursive(questions[1]);

            var priceByHour = ConsoleAppPrintUtil.PrintQuestionWithDecimalAnswerRecursive(questions[2]);

            var answerText = Exercise4GetAnswerText(name, hoursWorked, priceByHour);

            ConsoleAppPrintUtil.PrintText(answerText);
        }
Beispiel #10
0
        private static void Exercise1_2()
        {
            ConsoleAppPrintUtil.PrintTextWithLineSeparator("Ejercicio 1-2:");

            var questions = new string[] {
                "Introduzca un texto:"
            };

            var text = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[0]);

            try
            {
                var textParse = int.Parse(text);
                ConsoleAppPrintUtil.PrintText("Número correcto");
            }
            catch (Exception)
            {
                ConsoleAppPrintUtil.PrintText("Número incorrecto");
            }
        }
Beispiel #11
0
        private static void Exercise2()
        {
            ConsoleAppPrintUtil.PrintTextWithLineSeparator("Ejercicio 2:", useReadLine: false);

            ConsoleAppPrintUtil.PrintText("Complete los datos del alumno:", useConsoleClear: false);

            var questions = new string[] {
                "¿Cuáles son tus apellidos?",
                "¿Qué edad tienes?",
                "¿Cuál es tu nombre?"
            };

            var student = new Student();

            student.Name = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[2]);

            student.LastName = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[0]);

            student.Age = ConsoleAppPrintUtil.PrintQuestionWithIntAnswerLessThanRecursive(questions[1], 150);

            ConsoleAppPrintUtil.PrintText($"Los datos del alumno son > {student}.");
        }
Beispiel #12
0
        private static void Exercise2()
        {
            ConsoleAppPrintUtil.PrintTextWithLineSeparator("Ejercicio 2:");

            var answerOfQuestions = new List <object>();

            var questions = new string[] {
                "¿Cómo te llamas?",
                "¿Dónde vives?",
                "¿Cuántos años tienes?",
                "¿Te gusta el deporte?",
                "¿Hace calor hoy?"
            };

            var name = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[0]);

            answerOfQuestions.Add(name);

            var address = ConsoleAppPrintUtil.PrintQuestionWithStringAnswerRecursive(questions[1]);

            answerOfQuestions.Add(address);

            var age = ConsoleAppPrintUtil.PrintQuestionWithIntAnswerRecursive(questions[2]);

            answerOfQuestions.Add(age);

            var likeSport = ConsoleAppPrintUtil.PrintQuestionWithCharAnswerRecursive(questions[3], correctAnswers: new string [] { "S", "N" });

            answerOfQuestions.Add(likeSport);

            var hotDay = ConsoleAppPrintUtil.PrintQuestionWithCharAnswerRecursive(questions[4], correctAnswers: new string[] { "S", "N" });

            answerOfQuestions.Add(hotDay);

            Exercise2ShowAnswerOfQuestions(answerOfQuestions);
        }