public void AddPeople(People newPerson) { foreach (var person in this.people) { if(newPerson is Student && person is Student) { var newStudent = newPerson as Student; var student = person as Student; if(student.UniqueClassNumber == newStudent.UniqueClassNumber) { throw new ArgumentException("Class numbers of students must be UNIQUE!"); } } } this.people.Add(newPerson); }
public void RemovePeople(People oldPerson) { this.people.Remove(oldPerson); }