public Course(List <Student> _students, Teacher _teacher, Level _currentLevel, Modality _currentModality, int _durationMinutes) { List <Schedule> posibleSchedules = FindScheduleIntersection(_students, _teacher, _durationMinutes); if (!posibleSchedules.Count.Equals(0)) { Random rnd = new (); int randomIndex = rnd.Next(posibleSchedules.Count); if (ValidIndividualModality(_students, _currentModality)) { Students = _students; Teacher = _teacher; CurrentLevel = _currentLevel; CurrentSchedule = posibleSchedules.ElementAt(randomIndex); CurrentModality = _currentModality; } else if (ValidGroupModality(_students, _currentLevel, _currentModality)) { Students = _students; Teacher = _teacher; CurrentLevel = _currentLevel; CurrentSchedule = posibleSchedules.ElementAt(randomIndex); CurrentModality = _currentModality; } } else { throw new ArgumentException("No schedule available"); } }
public static Boolean ValidGroupModality(List <Student> _students, Level _currentLevel, Modality _currentModality) { if (_currentModality.CurrentModality.Equals(_Modality.Group) && _students.Count <= 6 && _students.All(student => student.CurrentModality.CurrentModality.Equals(_Modality.Group)) && _students.All(student => student.CurrentLevel.CurrentLevel.Equals(_currentLevel.CurrentLevel))) { return(true); } else { return(false); } }