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(); }
static void Main(string[] args) { Student Tania = new Student(); Console.WriteLine(Tania.ToString()); Console.WriteLine(Tania[Education.Bachelor]); Console.WriteLine(Tania[Education.Master]); Console.WriteLine(Tania[Education.SecondEducation]); Person ob = new Person("Tania", "Lunyk", new DateTime(1999, 09, 24)); Tania = new Student(ob, Education.Bachelor, 311); // Console.WriteLine(Tania.ToString()); Exam ob1 = new Exam("Math", 5, new DateTime(2018, 12, 16)); Exam[] ob2 = new Exam[] { ob1 }; Tania.AddExams(ob2); Console.WriteLine(Tania.ToString()); int column = 100; int row = 100; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); String[] exams1 = new string[column * row]; for (int i = 0; i < column * row; i++) { exams1[i] = ob1.ToString(); } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; // Format and display the TimeSpan value. string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds); Console.WriteLine("RunTime1 " + elapsedTime); Stopwatch stopWatch2 = new Stopwatch(); stopWatch2.Start(); String[,] exams2 = new string[column, row]; for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { exams2[i, j] = ob1.ToString(); } } stopWatch2.Stop(); TimeSpan ts2 = stopWatch2.Elapsed; // Format and display the TimeSpan value. string elapsedTime2 = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts2.Hours, ts2.Minutes, ts2.Seconds, ts2.Milliseconds); Console.WriteLine("RunTime2 " + elapsedTime2); Stopwatch stopWatch3 = new Stopwatch(); stopWatch3.Start(); String[][] exams3 = new string[row][]; for (int i = 0; i < row; i++) { exams3[i] = new string[column]; for (int j = 0; j < column; j++) { exams3[i][j] = ob.ToString(); } } stopWatch2.Stop(); TimeSpan ts3 = stopWatch3.Elapsed; // Format and display the TimeSpan value. string elapsedTime3 = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts3.Hours, ts3.Minutes, ts3.Seconds, ts3.Milliseconds); Console.WriteLine("RunTime2 " + elapsedTime3); /*string str, str1; * str = Console.ReadLine(); * int a; * int.TryParse(str, out a); * str1 = Console.ReadLine(); * int b = int.Parse(str1); * Console.WriteLine(a+b);*/ }
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 }
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 }
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 }
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 }