/// <summary> /// Add Teacher to the list of Teachers leading lectures in that class. /// </summary> /// <param name="teacher">Teacher instance to be added.</param> public void AddTeacher(Teacher teacher) { if (!this.Teachers.Contains(teacher)) { this.Teachers.Add(teacher); } }
public static void Main() { // Create & loads Teacher & Disciplines Teacher teacherOne = new Teacher("Goshko", "Goshkov"); Discipline disciplineOne = new Discipline("Mathematica", 4, 10); Discipline disciplineTwo = new Discipline("Phisics", 10, 6); teacherOne.AddDiscipline(disciplineOne); teacherOne.AddDiscipline(disciplineTwo); // Create & loads students Student studentOne = new Student("Petarcho", "Petarchov", 1); Student studentTwo = new Student("Yordancho", "Yordanov", 2); Student studentThree = new Student("Zuyo", "Zuev", 1); Student studentFour = new Student("Suzi", "Suzankovichkova", 2); // Create & loads class with students and teachers Class classOne = new Class("Class One"); try { classOne.AddStudent(studentOne); classOne.AddStudent(studentTwo); classOne.AddTeacher(teacherOne); } catch (ArgumentException e) { Console.WriteLine(e.Message); } Teacher teacherTwo = new Teacher("Petunia", "Petunkova", new Discipline("Rocket Science", 1000, 6000)); Class classTwo = new Class("Class Two"); try { classTwo.AddStudent(studentThree); classTwo.AddStudent(studentFour); classTwo.AddTeacher(teacherOne); classTwo.AddTeacher(teacherTwo); } catch (ArgumentException e) { Console.WriteLine(e.Message); } // Create & loads school and add class School school = new School(); school.AddClass(classOne); school.AddClass(classTwo); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("School details:"); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(school.ToString()); }
/// <summary> /// Removes Teacher from the list. /// If Teacher instance is not found, no change is applied. /// </summary> /// <param name="teacher">Instance of Teacher to be removed.</param> public void RemoveTeacher(Teacher teacher) { if (teacher != null) { if (this.Teachers.Contains(teacher)) { this.Teachers.Remove(teacher); } } else { throw new ArgumentNullException("teacher", "Teacher instance cannot be null!"); } }