コード例 #1
0
ファイル: Program.cs プロジェクト: carlitosfenix/git-exercici
        private static bool ExamenAlta()
        {
            LimpiarConsoleLine();
            Console.WriteLine("4 - 1) Alta de Examen.");
            Console.WriteLine("Para volver sin guardar examen entra *.");
            Console.WriteLine("Entra la nota del examen:");

            var  nota    = "";
            bool primera = true;

            ValidationResult <double> vrNote = Exam.ValidateNote(nota);

            do
            {
                if (!primera)
                {
                    Console.WriteLine(vrNote.AllErrors);
                }

                nota = Console.ReadLine();
                if (nota == "*")
                {
                    return(false);
                }
                primera = false;
            } while (!(vrNote = Exam.ValidateNote(nota)).IsSuccess);


            Console.WriteLine("La fecha, por ahora, será el timeStamp de Now.");
            DateTime date = DateTime.Now;

            primera = true;

            ValidationResult <DateTime> vrDate = Exam.ValidateDate(date);

            do
            {
                if (!primera)
                {
                    Console.WriteLine(vrDate.AllErrors);
                }

                date = DateTime.Now;
                // if (date == "*") return false;
                primera = false;
            } while (!(vrDate = Exam.ValidateDate(date)).IsSuccess);

            Console.WriteLine("Entra el dni del alumno:");
            primera = true;
            var dni = "";
            ValidationResult <Student> vrAlumno = Exam.ValidateStudent(dni, false);

            do
            {
                if (!primera)
                {
                    Console.WriteLine(vrAlumno.AllErrors);
                }

                dni = Console.ReadLine();
                if (dni == "*")
                {
                    return(false);
                }
                primera = false;
            } while (!(vrAlumno = Exam.ValidateStudent(dni, false)).IsSuccess);


            Console.WriteLine("Entra el nombre de la Materia:");
            var nameSubject = "";

            primera = true;

            ValidationResult <Subject> vrAsignatura = Exam.ValidateSubject(nameSubject, primera);

            do
            {
                if (!primera)
                {
                    Console.WriteLine(vrAsignatura.AllErrors);
                }

                nameSubject = Console.ReadLine();
                if (nameSubject == "*")
                {
                    return(false);
                }
                primera = false;
            } while (!(vrAsignatura = Exam.ValidateSubject(nameSubject, primera)).IsSuccess);



            if (vrNote.IsSuccess && vrDate.IsSuccess && vrAlumno.IsSuccess && vrAsignatura.IsSuccess)
            {
                Exam dummySubject = new
                                    Exam(vrAlumno.ValidatedResult,
                                         vrAsignatura.ValidatedResult, vrDate.ValidatedResult,
                                         vrNote.ValidatedResult);

                var sr = ExamRepository.Add(dummySubject);
                if (sr.IsSuccess)
                {
                    Console.WriteLine($"examen guardado correctamente");
                    return(true);
                }
                else
                {
                    Console.WriteLine($"uno o más errores han ocurrido y el examen no se ha guardado correctamente");
                }
                return(true);
            }
            return(false);;
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Number Num;

            Num.N = (int)Numbers.Lab;
            Num.G = (int)Numbers.Group;
            Num.C = (int)Numbers.Course;

            Console.WriteLine($"Лаб. раб. №{Num.N}.");
            Console.WriteLine($"Вариант {Num.G}.");
            Console.WriteLine($"{Num.G} группа.");
            Console.WriteLine($"{Num.C} курс.\n");

            Test Error = new Test();
            Test Test1 = new Test();

            Test1.Size = 10;
            Test Test2 = new Test();

            Test2.Size = 15;
            Zach Zachet = new Zach();

            Zachet.ZPush(Test1);
            Zachet.ZPush(Test2);
            Console.WriteLine($"Количество испытаний: {Zachet.GetLength()}");

            CControler  Controler = new CControler();
            List <Test> tests     = new List <Test>();

            tests = Zachet.Get();
            Controler.CPush(tests);
            Console.WriteLine("Поиск по количеству вопросов в тесте: 10.");
            int Find = Controler.Serch(10);

            switch (Find)
            {
            case 10:
            {
                Console.WriteLine("Test 1.");
                break;
            }

            case 15:
            {
                Console.WriteLine("Test 2.");
                break;
            }
            }

            Console.ReadKey();
            Console.Clear();

            #region Laba 5
            Console.WriteLine($"Лаб. раб. №5.");
            Question Vopros1 = new Question();
            Vopros1.Quest = "Какой-то easy вопрос.";
            Vopros1.ToString();
            Vopros1.Do();
            Vopros1.GetOut();

            Console.WriteLine();

            Test T1 = new Test();
            T1.T();
            T1.Testing = "Какой-то тест.";
            T1.ToString();
            T1.Do();
            T1.GetOut();

            Console.WriteLine();

            Exam Exam1 = new Exam();
            Exam1.E();
            Exam1.Examin = "Какой-то экзамен.";
            Exam1.ToString();
            Exam1.Do();
            Exam1.GetOut();

            Console.WriteLine();

            FinalExam FinEx1 = new FinalExam();
            FinEx1.FE();
            FinEx1.Final = "Какой-то выпускной экзамен.";
            FinEx1.ToString();
            FinEx1.Do();
            FinEx1.GetOut();

            Console.WriteLine();

            Console.ReadKey();
            #endregion
        }