Example #1
0
        public void AddStudentToCourse(Student student, Course course)
        {
            if (student == null)
            {
                throw new ArgumentNullException("Student cannot be null.");
            }

            if (!this.courses.Contains(course))
            {
                throw new ArgumentException("Course does not exists in this school.");
            }

            if (!this.students.Contains(student))
            {
                throw new ArgumentException("Student does not exists in this school.");
            }

            if (course.Students.Count >= course.StudentsCapacity)
            {
                throw new ArgumentException("Course capacity is filled.");
            }

            if (course.Students.Contains(student))
            {
                throw new ArgumentException(
                    string.Format("Student with number {0} already added in this course.", student.UniqueNumber));
            }

            course.Students.Add(student);
        }
Example #2
0
        public void RemoveStudentFromCourse(Student student, Course course)
        {
            if (student == null)
            {
                throw new ArgumentNullException("Student cannot be null.");
            }

            course.Students.Remove(student);
        }
Example #3
0
        public Course RegisterCourse(string name)
        {
            var course = new Course(name);

            if (this.courses.Contains(course))
            {
                throw new ArgumentException("Course is already added in the school.");
            }

            this.courses.Add(course);
            return course;
        }