示例#1
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");

            Question Vopros1 = new Question();

            Vopros1.Quest = "Какой-то easy вопрос.";
            Vopros1.ToString();
            Vopros1.Do();
            Vopros1.GetOut();

            Console.WriteLine();

            Test Test1 = new Test();

            Test1.T();
            Test1.Testing = "Какой-то тест.";
            Test1.ToString();
            Test1.Do();
            Test1.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();
        }
示例#2
0
        static void Main(string[] args)
        {
            Test      test1       = new Test("mathematic", 10);
            Exams     exam1       = new Exams("biolagy", 15);
            FinalExam final_exam1 = new FinalExam("fisiks", 11, 6);

            final_exam1.Clone();
            ((Ialive)final_exam1).Clone();

            Exams     exam2       = new Exams("chemistry", 20);
            FinalExam final_exam2 = exam2 as FinalExam;

            if (final_exam2 == null)
            {
                Console.WriteLine("No corret conversion");
            }

            FinalExam final_exan3 = new FinalExam("logistic", 12, 4);
            Exams     exam3       = final_exan3 as Exams;

            if (exam3 == null)
            {
                Console.WriteLine("No corret conversion");
            }
            else
            {
                Console.WriteLine("Corret conversion");
            }

            Console.WriteLine("test1 is Test " + (test1 is Test));
            Console.WriteLine("test1 is Exam " + (test1 is Exams));
            Console.WriteLine("exam1 is Test " + (exam1 is Test));
            Console.WriteLine("exam1 is Exam " + (exam1 is Exams));

            Console.WriteLine(exam2.ToString());

            Printer printer = new Printer();

            printer.IAmPrinting(final_exan3);

            Console.WriteLine("----------------------Array-----------------------");
            Question[] questions = new Question[] { test1, exam1, final_exam1 };
            for (int i = 0; i < questions.Length; i++)
            {
                printer.IAmPrinting(questions[i]);
                Console.WriteLine("--------------------------------------");
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            #region Laba 5
            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");

            #region Laba 14
            Question        Vopros       = new Question();
            BinaryFormatter binformatter = new BinaryFormatter();
            using (FileStream binfs = new FileStream("BinObj.dat", FileMode.OpenOrCreate))
            {
                binformatter.Serialize(binfs, Vopros);
                Console.WriteLine("Объект класса Question сериализован.");
            }
            using (FileStream binfs = new FileStream("BinObj.dat", FileMode.OpenOrCreate))
            {
                Question Vopros1 = (Question)binformatter.Deserialize(binfs);
                Console.WriteLine("Объект класса Question десериализован.\n\n");
                Vopros1.Quest = "Какой-то easy вопрос.";
                Vopros1.ToString();
                Vopros1.Do();
                Vopros1.GetOut();
                Console.WriteLine();
            }

            Test          Test       = new Test();
            SoapFormatter sformatter = new SoapFormatter();
            using (FileStream soapfs = new FileStream("SoapObj.dat", FileMode.OpenOrCreate))
            {
                sformatter.Serialize(soapfs, Test);
                Console.WriteLine("Объект класса Test сериализован.");
            }
            using (FileStream soapfs = new FileStream("SoapObj.dat", FileMode.OpenOrCreate))
            {
                Test Test0 = (Test)sformatter.Deserialize(soapfs);
                Console.WriteLine("Объект класса Test десериализован.\n\n");
                Test0.T();
                Test0.Testing = "Какой-то тест.";
                Test0.ToString();
                Test0.Do();
                Test0.GetOut();
                Console.WriteLine();
            }

            Exam          Exam0        = new Exam();
            XmlSerializer xmlformatter = new XmlSerializer(typeof(Exam));
            using (FileStream xmlfs = new FileStream("XmlObj.dat", FileMode.OpenOrCreate))
            {
                sformatter.Serialize(xmlfs, Exam0);
                Console.WriteLine("Объект класса Exam сериализован.");
            }
            using (FileStream xmlfs = new FileStream("XmlObj.dat", FileMode.OpenOrCreate))
            {
                Exam Exam1 = (Exam)sformatter.Deserialize(xmlfs);
                Console.WriteLine("Объект класса Exam десериализован.\n\n");
                Exam1.E();
                Exam1.Examin = "Какой-то экзамен.";
                Exam1.ToString();
                Exam1.Do();
                Exam1.GetOut();
                Console.WriteLine();
            }

            FinalExam FinEx0 = new FinalExam();
            DataContractJsonSerializer jsonFormatter = new DataContractJsonSerializer(typeof(FinalExam));

            using (FileStream jsonfs = new FileStream("FinalExam.json", FileMode.OpenOrCreate))
            {
                jsonFormatter.WriteObject(jsonfs, FinEx0);
                Console.WriteLine("Объект класса FinalExam сериализован.");
            }

            using (FileStream jsonfs = new FileStream("FinalExam.json", FileMode.OpenOrCreate))
            {
                FinalExam FinEx1 = (FinalExam)jsonFormatter.ReadObject(jsonfs);
                Console.WriteLine("Объект класса FinalExam десериализован.\n\n");
                FinEx1.FE();
                FinEx1.Final = "Какой-то выпускной экзамен.";
                FinEx1.ToString();
                FinEx1.Do();
                FinEx1.GetOut();
                Console.WriteLine();
            }


            ArrayList objectList = new ArrayList()
            {
                1, 2, 5, 10, "Array", "List"
            };
            DataContractJsonSerializer collect = new DataContractJsonSerializer(typeof(ArrayList));
            using (FileStream fs = new FileStream("ArrayList.json", FileMode.OpenOrCreate))
            {
                collect.WriteObject(fs, objectList);
            }
            using (FileStream fs = new FileStream("ArrayList.json", FileMode.OpenOrCreate))
            {
                ArrayList objects = (ArrayList)collect.ReadObject(fs);
                foreach (object o in objectList)
                {
                    Console.WriteLine(o);
                }
            }
            #endregion
            Console.ReadKey();
            #endregion
        }
示例#4
0
文件: Program.cs 项目: a4ekw/Labs
        static void Main(string[] args)
        {
            Console.WriteLine("Lab 8");

            Lab8 <int>    Objint = new Lab8 <int>();
            Lab8 <string> Objstr = new Lab8 <string>();
            string        str    = "String";
            int           I      = 8;

            Objint.Add(I);
            Objint.Out();
            Objstr.Add(str);
            Objstr.Out();
            int x = 0;

            try
            {
                Console.Write("Число > 0 : ");
                x = int.Parse(Console.ReadLine());
            }
            catch (FormatException)
            {
                Console.WriteLine("Это НЕ число!\n");
            }
            finally
            {
                Console.WriteLine("Блок Finally 1");
            }
            try
            {
                if (x <= 0)
                {
                    throw new ErrorData();
                }
            }
            catch (ErrorData e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                Console.WriteLine("Блок Finally 2");
            }
            Debug.Assert(x > 0, " Неверныый ввод!");
            Console.ReadKey();

            #region Laba 5
            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");

            Question Vopros1 = new Question();
            Vopros1.Quest = "Какой-то easy вопрос.";
            Vopros1.ToString();
            Vopros1.Do();
            Vopros1.GetOut();

            Console.WriteLine();

            Test Test1 = new Test();
            Test1.T();
            Test1.Testing = "Какой-то тест.";
            Test1.ToString();
            Test1.Do();
            Test1.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
        }
示例#5
0
        static void Main(string[] args)
        {
            #region Laba 6
            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 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();
            #endregion
            #region laba 7
            int x = 0;
            try
            {
                Console.Write("Количество вопросов в тесте: ");
                x = int.Parse(Console.ReadLine());
            }
            catch (FormatException)
            {
                Console.WriteLine("Это НЕ число!\n");
            }
            try
            {
                if (x <= 0)
                {
                    throw new ErrorData();
                }
            }
            catch (ErrorData e)
            {
                Console.WriteLine(e.Message);
            }

            Debug.Assert(x < 0, " Неверныый ввод!");
            try
            {
                Find = Controler.Serch(x);
            }
            catch (FindTestException e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadKey();
            Console.Clear();
            #endregion
            #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
        }
示例#6
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
        }