Beispiel #1
0
 public ClashFinder(List <SubjectModel> selectedSubjects, Func <Slot[], List <List <Slot> > > permutator,
                    SubjectModel target)
 {
     _selectedSubjects = selectedSubjects;
     _target           = target;
     if (selectedSubjects.Count == 2)
     {
         ClashingSubjects = (
             new SubjectModelWithState(target.Name, null),
             new SubjectModelWithState(selectedSubjects.Find(x => x.Code != target.Code).Name, null));
         return;
     }
     for (var i = 0; i < selectedSubjects.Count; i++)
     {
         SubjectModel s            = selectedSubjects[i];
         int[]        subjectState = GetSubjectState(permutator(s.GetSelectedSlots().ToArray()));
         _subjectStateList.Add(new SubjectModelWithState(s.Name, subjectState));
     }
     for (int i = 0; i < _subjectStateList.Count; i++)
     {
         for (int j = 0; j < _subjectStateList.Count; j++)
         {
             if (i == j)
             {
                 continue;
             }
             if (_subjectStateList[i].ClashesWith(_subjectStateList[j]))
             {
                 ClashingSubjects = (_subjectStateList[i], _subjectStateList[j]);
                 return;
             }
         }
     }
     ClashingSubjects = null;
 }
Beispiel #2
0
        public ClashFinder(List <SubjectModel> subjectModels, Func <Slot[], List <List <Slot> > > permutator)
        {
            var selectedSubjects = subjectModels.FindAll(x => x.IsSelected);

            for (var i = 0; i < selectedSubjects.Count; i++)
            {
                SubjectModel s            = selectedSubjects[i];
                int[]        subjectState = GetSubjectState(permutator(s.GetSelectedSlots().ToArray()));
                _subjectStateList.Add(new SubjectModelWithState(s.Name, subjectState));
            }
            for (int i = 0; i < _subjectStateList.Count; i++)
            {
                for (int j = 0; j < _subjectStateList.Count; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }
                    if (_subjectStateList[i].ClashesWith(_subjectStateList[j]))
                    {
                        Message = $"Because\n--{_subjectStateList[i].SubjectName}\nclashes with\n--{_subjectStateList[j].SubjectName}";
                        return;
                    }
                }
            }
            Message = $"Sorry... the reason is too complicated to be explained.";
        }