コード例 #1
0
ファイル: greedy.cs プロジェクト: ztang1253/ZTExamTable
        private static int getValidStartTimeValue(int startValue, double duration)
        {
            startValue = adjustStartValue(startValue);
            int weekDay         = startValue / 10000;
            int startHour       = startValue % 10000;
            int standardDuation = TimeValueInterval.hoursStandardValue(duration);
            int startNow        = startHour + standardDuation;
            int startPM         = MIN_PM_HOUR + standardDuation;
            int startAM         = MIN_AM_HOUR + standardDuation;

            if (startHour >= MIN_AM_HOUR && startNow <= MAX_AM_HOUR)
            {
                return(startValue);
            }
            else if (startHour >= MIN_PM_HOUR && startNow <= MAX_PM_HOUR)
            {
                return(startValue);
            }
            else if (startHour < MIN_PM_HOUR && startPM < MAX_PM_HOUR)
            {
                return(weekDay * 10000 + MIN_PM_HOUR);
            }
            else if (startAM < MAX_AM_HOUR)
            {
                return((weekDay + 1) * 10000 + MIN_AM_HOUR);
            }
            else if (startPM < MAX_PM_HOUR)
            {
                return((weekDay + 1) * 10000 + MIN_PM_HOUR);
            }

            Console.WriteLine("Error!!!!!! Duration is too long!!!!!!!!");
            return(-1);
        }
コード例 #2
0
ファイル: greedy.cs プロジェクト: ztang1253/ZTExamTable
        public SpecialEntity(string course, string room, int session, string protor, string week, string hour, string d)
        {
            courseId  = string2Int(course);
            roomId    = string2Int(room);
            sessionId = session;
            protorId  = string2Int(protor);
            int    weekDay   = string2Int(week);
            double startHour = Convert.ToDouble(hour);
            double duration  = Convert.ToDouble(d);

            timeData = new TimeValueInterval(weekDay * 10000 + TimeValueInterval.hoursStandardValue(startHour), duration);
        }