Example #1
0
        private int getCount(TeacherLessonCollection tlc, int presetDayOfWeek, int presetSection)
        {
            int sum = 0;

            foreach (TeacherLesson tl in tlc)
            {
                if ((weekCondition(tl.DayOfWeek, presetDayOfWeek) && sectionCondition(tl.Section, presetSection)) == Predication)
                {
                    sum++;
                }
            }
            return(sum);
        }
Example #2
0
        /// <summary>
        /// 返回指定教师的某一天的所有课程
        /// </summary>
        /// <param name="dayOfWeek">从零开始的星期</param>
        /// <returns></returns>
        public TeacherLessonCollection GetDOWLessons(int dayOfWeek)
        {
            TeacherLessonCollection tlc = new TeacherLessonCollection(_teacherID);

            foreach (TeacherLesson tl in _teacherLessonDictionary.Values)
            {
                if (tl.DayOfWeek == dayOfWeek)
                {
                    tlc.Add(dayOfWeek, tl.Section, tl);
                }
            }

            return(tlc);
        }
Example #3
0
        public override int GetWeight(Schedule s)
        {
            int             sum = 0;
            TeacherSchedule ts  = s.TeacherSchedule;

            //对所有教师都成立的规则
            if (TeacherID == -1)
            {
                foreach (TeacherLessonCollection tlc in ts)
                {
                    sum += getCount(tlc, DayOfWeek, Section);
                }
            }
            else
            {
                TeacherLessonCollection tlc = ts[TeacherID];
                sum = getCount(tlc, DayOfWeek, Section);
            }



            return(sum * Weight);
        }