예제 #1
0
        public void RemoveStudent(Student studentToRemove)
        {
            if (!this.StudentExists(studentToRemove))
            {
                throw new ArgumentException("No such student exists in this course");
            }

            this.students.Remove(studentToRemove);
        }
예제 #2
0
        private bool StudentExists(Student studentToCheck)
        {
            bool isFound = false;

            foreach (var stu in this.students)
            {
                if (studentToCheck.UniqueNumber == stu.UniqueNumber)
                {
                    isFound = true;
                    break;
                }
            }

            return isFound;
        }
예제 #3
0
 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);
     }
 }