static void Main(string[] args) { try { Exams exams1 = new Exams("Biology", 4, 5); FinalExam finalexam1 = new FinalExam("Logistik", 6, 5); Exams exams2 = new Exams("Biology", 4, 3); FinalExam finalexam2 = new FinalExam("Logistik", 6, 5); Session.Add(exams1); Session.Add(exams2); Session.Add(finalexam1); Session.Add(finalexam2); Console.WriteLine("----------------------------------------------"); Session.ShowList(); Console.WriteLine("----------------------------------------------"); int counter = Contreller.CounterOfExams(Session.All_exams); Console.WriteLine("Counter of exams{0}", counter); Console.WriteLine("----------------------------------------------"); Contreller.Find_By_Number_Of_Exams(Session.All_exams); Console.WriteLine("----------------------------------------------"); Contreller.Find_By_Topic(Session.All_exams); Console.WriteLine("----------------------------------------------"); Session.First_Exmas first_exams; Console.WriteLine("Введите какой экзамен будет первым"); first_exams.exams = Console.ReadLine(); Console.WriteLine("Сколько всего будет экзаменов"); switch (int.Parse(Console.ReadLine())) { case (int)Session.First_Exmas.Examss.first: Console.WriteLine("будет один экзамен"); break; case (int)Session.First_Exmas.Examss.second: Console.WriteLine("будет два экзамен"); break; case (int)Session.First_Exmas.Examss.third: Console.WriteLine("будет три экзамен"); break; default: Console.WriteLine("не может быть столько экзаменов"); break; } } catch { } }
static void Main(string[] args) { string[] str = new string[5]; try { str[4] = "anything"; Console.WriteLine("It's OK"); } catch (IndexOutOfRangeException e) { Console.WriteLine("IndexOutOfRangeException"); } catch (Exception e) { Console.WriteLine("Exception"); } try { Console.WriteLine("////////////////////////////////////////////////"); try { Test tes1 = new Test("La", 4, 5, 6); } catch (IsNotTopic ex) { Console.WriteLine($"{ex.Message}\n{ex.Source}\n{ex.StackTrace}"); } Console.WriteLine("////////////////////////////////////////////////"); try { Exams exam = new Exams("Biology", 6, 4, 3); exam.Numbers = 3; } catch (WrongNumbersValue ex) { Console.WriteLine($"{ex.Message}\n{ex.Source}\n{ex.StackTrace}"); } Console.WriteLine("////////////////////////////////////////////////"); try { FinalExam final_exam = new FinalExam("Logistik", 5, 6, 11); final_exam.Id = -3; } catch (WrongIdValue ex) { Console.WriteLine($"{ex.Message}\n{ex.Source}\n{ex.StackTrace}"); } Console.WriteLine("////////////////////////////////////////////////"); Test test2 = new Test("Mathematic", 4, 5, 11); Exams exam2 = new Exams("Fisikz", 6, 4, 0); FinalExam final_exam2 = new FinalExam("Blogs", 5, 6, 32); Question[] questions = new Question[] { test2, exam2, final_exam2 }; try { Console.WriteLine(questions[4].Numbers); } catch (IndexOutOfRangeException ex) { Console.WriteLine($"{ex.Message}\n{ex.Source}\n{ex.StackTrace}"); } Console.WriteLine("////////////////////////////////////////////////"); try { object obj = exam2.Topic; int name = (int)obj; } catch (InvalidCastException ex) { Console.WriteLine($"{ex.Message}\n{ex.Source}\n{ex.StackTrace}"); } Console.WriteLine("////////////////////////////////////////////////"); try { double count = test2.Numbers / exam2.Id; } catch (DivideByZeroException ex) { Console.WriteLine($"{ex.Message}\n{ex.Source}\n{ex.StackTrace}"); } Console.WriteLine("////////////////////////////////////////////////"); test2.days(); } catch (Exception ex) { Console.WriteLine($"{ex.Message}\n{ex.Source}\n{ex.StackTrace}"); } finally { Console.WriteLine("Блок finally"); } }