예제 #1
0
        static public void ShowHighAchiversCommand()
        {
            StudentRegistry.GetInstance().visitStudents(new HighAchieverVisitor());

            /*
             * StudentRegistry a = StudentRegistry.GetInstance();
             * int len = a.getStudentCount();
             *
             * for (int i = 0; i < len; i++)
             * {
             *  Student st = a.getStudent(i);
             *  HighAchieverVisitor arq = new HighAchieverVisitor();
             *  arq.startVisit();
             *  arq.visitStudent(i + 1, st);
             *  //
             *  bool good = true;
             *  Student stu = a.getStudent(i);
             *  foreach (KeyValuePair<string, int> item in stu.marks)
             *  {
             *      if (item.Value < 5)
             *      {
             *          good = false;
             *      }
             *  }
             *  if (good)
             *  {
             *      stu.print_Short();
             *  }
             *  //
             * }
             */
        }
예제 #2
0
        static public void RemoveStudentCommand()
        {
            StudentRegistry.GetInstance().visitStudents(new BriefPrintVisitor());
            StudentRegistry a = StudentRegistry.GetInstance();


            if (a.getStudentCount() > 0)
            {
                int n;
                Console.WriteLine("Введите номер: ");
                n = Convert.ToInt32(Console.ReadLine());
                while (n <= 0 || n > a.getStudentCount())
                {
                    Console.WriteLine("Введён неверный номер!");
                    Console.WriteLine("Введите номер: ");
                    n = Convert.ToInt32(Console.ReadLine());
                }
                Console.WriteLine("Вы уверены? y/n ");
                string vp;
                vp = Console.ReadLine();
                if (vp == "y")
                {
                    a.removeStudent(n - 1);
                    Console.WriteLine("Удалён успешно!");
                }
            }
        }
예제 #3
0
 public static StudentRegistry GetInstance()
 {
     if (instance == null)
     {
         instance = new StudentRegistry();
     }
     return(instance);
 }
예제 #4
0
        static public void  ListStudentsCommand()
        {
            StudentRegistry.GetInstance().visitStudents(new DetaliedPrintVisitor());

            /*
             * StudentRegistry  a = StudentRegistry.GetInstance();
             * int len = a.getStudentCount();
             * Student st = a.getStudent(0);
             * //Console.WriteLine("===" + (i + 1) + "===");
             * //st.print_Long();
             * DetaliedPrintVisitor ar = new DetaliedPrintVisitor();
             * ar.startVisit();
             * ar.visitStudent(0 + 1, st);
             */
        }
예제 #5
0
        static public void AddStudentCommand()
        {
            StudentRegistry a = StudentRegistry.GetInstance();
            string          name, srname, ot, gr;

            Console.WriteLine("Введите имя: ");
            name = Console.ReadLine();
            Console.WriteLine("Введите фамилию: ");
            srname = Console.ReadLine();
            Console.WriteLine("Введите отчество: ");
            ot = Console.ReadLine();
            Console.WriteLine("Введите группу: ");
            gr = Console.ReadLine();

            a.AddStudent(new Student(srname, name, ot, gr));
            Console.WriteLine("Успешно добавлен!");
        }
예제 #6
0
        public static void SelectStudentCommand()
        {
            StudentRegistry.GetInstance().visitStudents(new BriefPrintVisitor());
            Console.WriteLine("Введите порядковый номер студента (от 1 до " + StudentRegistry.GetInstance().getStudentCount() + " включительно): ");
            int nv = Convert.ToInt32(Console.ReadLine());

            if (StudentRegistry.GetInstance().getStudentCount() > 0)
            {
                while (nv < 1 && nv > StudentRegistry.GetInstance().getStudentCount())
                {
                    Console.WriteLine("Введён неверный номер!");
                    Console.WriteLine("Введите порядковый номер студента (от 1 до " + StudentRegistry.GetInstance().getStudentCount() + " включительно): ");
                    nv = Convert.ToInt32(Console.ReadLine());
                }
                EditContext.GetInstance().student = StudentRegistry.GetInstance().getStudent(nv - 1);
            }
            else
            {
                throw new Exception("No students in base!");
            }
        }