Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }