public void AddStudent(Student student) { if (this.Students.Count < MaxStudentCount) { this.students.Add(student); } else { Console.WriteLine("Course is full!"); } }
public void AddStudent(Student student) { var studentWithSameUNIsEnlisted = this.uniqueStudentNumbers.IndexOf(student.UniqueNumber); if (studentWithSameUNIsEnlisted >= 0) { Console.WriteLine("Student with unique number: {0} is already enlisted in this school!", student.UniqueNumber); return; } this.students.Add(student); this.uniqueStudentNumbers.Add(student.UniqueNumber); }
public void RemoveStudent(Student student) { var studentIndexInCourse = this.students.IndexOf(student); if (studentIndexInCourse >= 0) { this.students.Remove(student); Console.WriteLine("Student removed succesfully!"); } else { Console.WriteLine("Student was not found in this course!"); } }