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> /// Remove class instance from school. /// If class instance is not discovered, no changes are applied. /// </summary> /// <param name="studentClass">Instance of a student class to be removed from school list.</param> public void RemoveClass(Class studentClass) { if (studentClass != null) { if (this.Classes.Contains(studentClass)) { this.classes.Remove(studentClass.Id); } } else { throw new ArgumentNullException("studentClass", "Class instance can not be null!"); } }
/// <summary> /// Add Instance of a Class to school list of student classes. /// </summary> /// <param name="studentClass">Instance of a student class to be added to the list of school classes.</param> public void AddClass(Class studentClass) { if (studentClass != null) { if (!this.Classes.Contains(studentClass)) { this.classes.Add(studentClass.Id, studentClass); } else { throw new ArgumentException("This instance of class already exist in the school list of classes!"); } } else { throw new ArgumentNullException("studentClass", "Class instance can not be null!"); } }