private void ShowButton_Click(object sender, RoutedEventArgs e) { string surname = SurnameTextBox.Text; int course; while (!int.TryParse(CourseTextBox.Text, out course)) { throw new Exception("Format Exception"); } int midPoint; while (!int.TryParse(MidPointTextBox.Text, out midPoint)) { throw new Exception("Format Exception"); } if (DerivedStudentRBut.IsChecked == true) { Student myStudent = new DerivedStudent(surname, midPoint, course, (bool)KnownEng.IsChecked); ShowingLabel.Content = myStudent.GetInformation(); } else { Student myBaseStudent = new Student(surname, midPoint, course); ShowingLabel.Content = myBaseStudent.GetInformation(); } }
static void Main(string[] args) { while (true) { Console.WriteLine("Surname:"); string surname = Console.ReadLine(); int course = IntParser("Course:"); int midpoint = IntParser("MidPoint:"); int classChoice = IntParser("1-BaseStudent; 2-DerivedStudent;"); if (classChoice == 2) { int actionEnglish; Student MyDerivedStudent = null; do { actionEnglish = IntParser("1-known english; 2 - no"); if (actionEnglish == 1) { MyDerivedStudent = new DerivedStudent(surname, midpoint, course, true); } if (actionEnglish == 2) { MyDerivedStudent = new DerivedStudent(surname, midpoint, course, false); } }while (actionEnglish != 1 && actionEnglish != 2); Console.WriteLine(MyDerivedStudent.GetInformation()); } else { Student myBaseStudent = new Student(surname, midpoint, course); Console.WriteLine(myBaseStudent.GetInformation()); } } }