public void RemoveStudent(Student studentToRemove) { if (studentToRemove == null) { throw new ArgumentNullException("You can not pass null as parameter, Student is expected"); } this.studentList.Remove(studentToRemove); }
public void RegisterStudent(Student studentToRegister) { if (studentToRegister == null) { throw new ArgumentNullException("You can not pass null as parameter, Student is expected"); } if (this.studentList.Any(x => x.StudentNumber == studentToRegister.StudentNumber)) { throw new ArgumentException("You can not add students with duplicating students numbers"); } this.studentList.Add(studentToRegister); }
public void AddStudent(Student studentToAdd) { if (studentToAdd == null) { throw new ArgumentNullException("You can not pass null as parameter, Student is expected"); } if (this.studentList.Count >= MaxStudentsCount) { throw new ArgumentOutOfRangeException("Class is full, you can not add more students"); } this.studentList.Add(studentToAdd); }