Exemplo n.º 1
0
 public void Delete(Isp El)
 {
     for (int i = 0; i < Session1.Count; i++)
     {
         if (El.Equals(Session1[i]))
         {
             Session1.RemoveAt(i);
         }
     }
 }
Exemplo n.º 2
0
        private static void Lab6()
        {
            Exam first = new First()
            {
                name = "Math", GradExam = 9, Kolvo = 4
            };
            Isp quest = new Question()
            {
                name = "Graphic", GradExam = 7
            };

            quest.Show();
            first.Show();

            Console.WriteLine();
            Test task = new Test()
            {
                name = "Grammar (16quest)", GradExam = 10, Kolvo = 7
            };

            task.Show();
            Question tom = new Question()
            {
                name = "Gr (8quest)", GradExam = 6, Kolvo = 1
            };

            tom.Show();

            Console.WriteLine();
            Question exam = new Question()
            {
                name = "Litersture", Kolvo = 3
            };

            exam.FirstQuestion();
            exam.Show();

            Console.WriteLine();
            IGradExam first1 = new First()
            {
                name = "Music", GradExam = 9, Kolvo = 9
            };                                                                           //Обращение через интерфейсную ссылку

            first1.Show();
            IGradExam test = new Test()
            {
                name = "Chemistry", GradExam = 5, Kolvo = 6
            };

            test.Show();


            //операторы is и as
            Console.WriteLine();
            Test    test1     = new Test();
            Boolean checkProd = test1 is Test;

            if (checkProd == true)
            {//Возвращает булевское значение, говорящее о том,
                //можете ли вы преобразовать данное выражение в указанный тип
                Console.WriteLine("test1 is Test");
            }
            Console.WriteLine("test1 {0} System.ValueType",
                              test is ValueType ? "is" : "is not");
            Console.WriteLine("test1 {0} Test",
                              test is Test ? "is" : "is not");
            // позволяет преобразовывать тип в определенный ссылочный тип
            Console.WriteLine();
            Question second  = new Question();
            Isp      QSecond = second as Isp;

            QSecond.FirstQuestion();

            Console.WriteLine();
            IGradExam[] array = new IGradExam[4];
            array[0] = first;
            array[1] = quest;
            array[2] = test;
            array[3] = exam;
            Printer printer = new Printer();

            for (int i = 0; i < 4; i++)
            {
                printer.IAmPrinting(array[i]);
            }

            User user1;

            user1.name = "User1";
            user1.age  = 19;
            user1.DisplayInfo();

            User user2 = new User("User2", 23);

            user2.DisplayInfo();

            user1 = user2; //Переменные хранят не ссылку на объект, а сам объект. Т.е. при присваивании одной структуре другую, скопируются все поля
            user1.DisplayInfo();
            Console.WriteLine();

            Operation op;

            op = Operation.Add;
            Console.WriteLine((int)op);
            op = Operation.Multiply;
            Console.WriteLine(op);
            Console.WriteLine();

            task.Questions.Add(new Question()
            {
                name = "Litr", Kolvo = 3
            });
            task.Questions.Add(new Question()
            {
                name = "Bio", Kolvo = 5
            });
            task.Questions.Add(new Question()
            {
                name = "Mat", Kolvo = 10
            });
            task.Questions.Add(new Question()
            {
                name = "Phiz", Kolvo = 15
            });
            task.Questions.Add(new Question()
            {
                name = "Chim", Kolvo = 10
            });

            Session Session = new Session();

            Session.Push(first);
            Session.Push(exam);
            Session.Push(quest);
            Session.Push(task);

            Session.Show();
            Console.WriteLine();

            Session.Delete(first);
            Session.Show();
            Console.WriteLine();

            Controller ses = new Controller(Session);

            Console.WriteLine("vse isp: " + ses.GetCount());
            Console.WriteLine("kolvo testov: " + ses.GetTestCount(5));

            Console.ReadLine();
        }
Exemplo n.º 3
0
 public void Push(Isp El)
 {
     Session1.Add(El);
 }