public void RemoveStudent(Student studentToRemove) { if (!this.StudentExists(studentToRemove)) { throw new ArgumentException("No such student exists in this course"); } this.students.Remove(studentToRemove); }
private bool StudentExists(Student studentToCheck) { bool isFound = false; foreach (var stu in this.students) { if (studentToCheck.UniqueNumber == stu.UniqueNumber) { isFound = true; break; } } return isFound; }
public void AddStudent(Student studentToAdd) { if (this.StudentExists(studentToAdd)) { throw new ArgumentException("Student {0} is already taking this course", studentToAdd.Name); } else if (this.students.Count >= MaxNumberOfStudentPerCourse) { throw new ArgumentException("The {0} course is full. No more students can sing for this course", this.CourseName); } else { this.students.Add(studentToAdd); } }