예제 #1
0
파일: Demo.cs 프로젝트: Ristinbk/Lab2.4
        private static void ShowMenuSessions(Univercity U)
        {
            Console.Write("1 - Добавить запись\n2 - Удалить запись\n3 - Изменить результат экзамена\n4 - Вывести список сессий\n" +
                          "5 - Вывести результаты экзамена для группы\n0 - В главное меню");
            int s;

            do
            {
                Console.Write("\nВведите соответствуещее значение: ");
                s = Int32.Parse(Console.ReadLine());
                switch (s)
                {
                case 1:
                    U.AddSession(new Session(InputSessionType(), DateTime.Now.Year));
                    break;

                case 2:
                    U.RemoveSession(InputSession());
                    break;

                case 3:
                    U.MoveResultPerson(InputSession(), InputNumberGroup(), InputId(), InputNameSubject(), InputAssessment());
                    break;

                case 4:
                    ShowSession(U);
                    break;

                case 5:
                    ShowResultOfSubject(U, InputSession(), InputNumberGroup(), InputNameSubject());
                    break;
                }
            } while (s != 0);
        }
예제 #2
0
파일: Demo.cs 프로젝트: Ristinbk/Lab2.4
        public static void InitializeUnivercity(Univercity U)
        {
            Random Rand = new Random();

            U.AddGroup(new Group(new NumberGroup(Specialty.Informatics, 2018)));
            U.AddGroup(new Group(new NumberGroup(Specialty.StateAudit, 2018)));

            U.Students.Add(new Student(new FullName("Илья", "Иванов", "Андреевич"), GetRandDate()));
            U.Students.Add(new Student(new FullName("Петр", "Борисов", "Петрович"), GetRandDate()));

            U.Groups[0].AddStudent(new Student(new FullName("Илья", "Иванов", "Андреевич"), GetRandDate()));
            U.Groups[0].AddStudent(new Student(new FullName("Иван", "Петров", "Олегович"), GetRandDate()));
            U.Groups[0].AddStudent(new Student(new FullName("Мария", "Иванова", "Олеговна"), GetRandDate()));
            U.Groups[1].AddStudent(new Student(new FullName("Ольга", "Зинко", "Евгеньевна"), GetRandDate()));
            U.Groups[1].AddStudent(new Student(new FullName("Петр", "Борисов", "Петрович"), GetRandDate()));


            U.AddTeacher(new Teacher(new FullName("Илья", "Смирнов", "Олегович"), GetRandDate(), Title.Aspirant));
            U.AddTeacher(new Teacher(new FullName("Борис", "Петров", "Дмитриевич"), GetRandDate(), Title.Lecture));
            U.AddTeacher(new Teacher(new FullName("Мария", "Иванова", "Олеговна"), GetRandDate(), Title.Lecture));

            List <ISubject> winterSession = new List <ISubject>()
            {
                new Subject("Математика", SubjectType.Exem),
                new Subject("Физика", SubjectType.Exem),
                new Subject("Информатика", SubjectType.Credited),
                new Subject("Психология", SubjectType.Credited)
            };
            List <ISubject> summerSession = new List <ISubject>()
            {
                new Subject("Английский", SubjectType.Credited),
                new Subject("История", SubjectType.Credited)
            };

            U.Subjects.AddRange(winterSession);
            U.Subjects.AddRange(summerSession);

            foreach (var t in U.Subjects)
            {
                t.AddTeacher(GetRandTeacher());
            }

            U.AddSession(new Session(SessionType.Winter, 2018));
            U.AddSession(new Session(SessionType.Summer, 2018));
            U.Sessions[0].AddSubjects(U.Subjects);
            U.Sessions[1].AddSubjects(summerSession);

            foreach (var session in U.Sessions)
            {
                foreach (var group in U.Groups)
                {
                    session.AddSubjectsInGroup(group);
                }
            }

            U.Sessions[0].Groups[0].Students.ForEach(delegate(IStudent student)
            {
                student.Subjects.ForEach(delegate(ISubject subject)
                {
                    subject.AddAssessment(GetRandAssessment());
                });
            });

            U.Sessions[0].Groups[1].Students.ForEach(delegate(IStudent student)
            {
                student.Subjects.ForEach(delegate(ISubject subject)
                {
                    subject.AddAssessment(GetRandAssessment());
                });
            });

            foreach (var subject in U.Subjects)
            {
                subject.AddTeacher(GetRandTeacher());
            }

            DateTime GetRandDate()
            {
                return(new DateTime(Rand.Next(1800, 1890), Rand.Next(1, 13), Rand.Next(1, 29)));
            }

            ITeacher GetRandTeacher()
            {
                return(U.Teachers[Rand.Next(U.Teachers.Count)]);
            }

            Assessment GetRandAssessment()
            {
                return((Assessment)Rand.Next(Enum.GetNames(typeof(Assessment)).Length));
            }
        }