Ejemplo n.º 1
0
 public Class(StudentGroup aGroup, Course aCourse, TimeSpan aLength, Room aRoom)
 {
     group = aGroup;
     course = aCourse;
     length = aLength;
     room = aRoom;
 }
Ejemplo n.º 2
0
 public TimeSpan GetStartTime(int aDay, StudentGroup aGroup)
 {
     if (aDay >= startTimes.Length || aDay < 0)
         throw new ArgumentOutOfRangeException("aDay", "Day should be between 0 and 6");
     if (!startTimes[aDay].ContainsKey(aGroup))
         throw new ArgumentException("Student group not found", "aGroup");
     return startTimes[aDay][aGroup];
 }
 /// <summary>
 /// A dictionary of StudentGroups and corresponding List of Classes
 /// </summary>
 /// <param name="index">The day of the week.</param>
 /// <returns></returns>
 public void DaysChangedGroupAdded(StudentGroup aGroup)
 {
     for (int day = 0; day < days.Length; day++)
     {
         if (days[day].ContainsKey(aGroup))
         days[day][aGroup].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Value_CollectionChanged);
     }
 }
        private void buttonCreateGroup_Click(object sender, RoutedEventArgs e)
        {
            if (txtGroupName.Text.Trim() != string.Empty)
            {
                StudentGroup newGroup = new StudentGroup(txtGroupName.Text);
                if (Configuration.Instance.Groups.Contains(newGroup))
                {
                    MessageBox.Show("Group already exists!");
                    return;
                }
                Configuration.Instance.Groups.Add(newGroup);

            }
            else MessageBox.Show("A group name is required.");
        }
Ejemplo n.º 5
0
 public TimeSpan GetStartTimeForClass(int aDay, StudentGroup aGroup, Class aClass)
 {
     if (aDay < 0 || aDay >= days.Length) throw new ArgumentOutOfRangeException("aDay", "Day should be between 0 and 6");
     if (aGroup == null) throw new ArgumentNullException("aGroup");
     if (aClass == null) throw new ArgumentNullException("aClass");
     if (!startTimes[aDay].ContainsKey(aGroup))
         throw new ArgumentException("Student group not found in start times", "aGroup");
     if (!days[aDay].ContainsKey(aGroup))
         throw new ArgumentException("Student group not found", "aGroup");
     TimeSpan startTime = startTimes[aDay][aGroup];
     foreach (var cl in days[aDay][aGroup])
     {
         if (cl == aClass)
         {
             return startTime;
         }
         startTime += cl.Length;
     }
     throw new ArgumentException(string.Format("{0} does not exist in day {1}, group {2}", aClass, aDay, aGroup));
 }
Ejemplo n.º 6
0
        private void TestRoomTimeOverlap3()
        {
            config.Clear();

            Stopwatch s = new Stopwatch();

            var mitov = new Professor("Kiril Mitov");
            var abrama = new Professor("Janet Abramowitch");

            var r12 = new Room("12", CourseType.NormalCourse);
            var r24 = new Room("24", CourseType.NormalCourse);
            var r32 = new Room("32", CourseType.ComputerCourse);

            var g11a = new StudentGroup("11A");
            var g11g = new StudentGroup("11G");

            var tp = new Course("TP", mitov, CourseType.ComputerCourse);
            var maths = new Course("Maths", abrama, CourseType.NormalCourse);

            var tp11a = new Class(g11a, tp, new TimeSpan(1, 20, 0), r32);
            var math11g = new Class(g11g, maths, new TimeSpan(2, 0, 0), r32);

            config.Rooms.Add(r12);
            config.Rooms.Add(r24);
            config.Rooms.Add(r32);

            config.Groups.Add(g11a);
            config.Groups.Add(g11g);

            config.Professors.Add(mitov);
            config.Professors.Add(abrama);

            config.Courses.Add(tp);
            config.Courses.Add(maths);

            Schedule sched = new Schedule();
            for (int i = 0; i < 7; i++)
            {
                sched.SetStartTime(i, g11a, new TimeSpan(8, 0, 0));
                sched.SetStartTime(i, g11g, new TimeSpan(10, 0, 0));
            }
            sched[0][g11a] = new ObservableCollection<Class>();
            sched[0][g11g] = new ObservableCollection<Class>();

            sched[0][g11a].Add(tp11a);//11A class has TP from 8AM to 9:20AM in room 32
            sched[0][g11g].Add(math11g);//11G class has Maths from 10AM to 12AM in room 32
            //result should be true, rooms do not conflict
            s.Start();
            IConstraint c = new RoomTimeOverlapConstraint();
            var result = c.Check(sched);
            s.Stop();

            string pass = result.ConstraintFulfilled == true ? "succeeded" : "failed";
            Console.WriteLine("TestRoomTimeOverlap3() " + pass);
            Console.WriteLine(result.ErrorMessage);
            Console.WriteLine("{0} ms.", s.ElapsedMilliseconds);
        }
Ejemplo n.º 7
0
        private void TestProfessorDayAndTimeOff()
        {
            config.Clear();

            Stopwatch s = new Stopwatch();

            var mitov = new Professor("Kiril Mitov");
            var abrama = new Professor("Janet Abramowitch");

            var r12 = new Room("12", CourseType.NormalCourse);
            var r24 = new Room("24", CourseType.NormalCourse);
            var r32 = new Room("32", CourseType.ComputerCourse);

            var g11a = new StudentGroup("11A");
            var g11g = new StudentGroup("11G");

            var tp = new Course("TP", mitov, CourseType.ComputerCourse);
            var maths = new Course("Maths", abrama, CourseType.NormalCourse);

            var tp11a = new Class(g11a, tp, new TimeSpan(1, 20, 0), r32);
            var tp11g = new Class(g11g, tp, new TimeSpan(1, 20, 0), r24);

            config.Rooms.Add(r12);
            config.Rooms.Add(r24);
            config.Rooms.Add(r32);

            config.Groups.Add(g11a);
            config.Groups.Add(g11g);

            config.Professors.Add(mitov);
            config.Professors.Add(abrama);

            config.Courses.Add(tp);
            config.Courses.Add(maths);

            Schedule sched = new Schedule();
            for (int i = 0; i < 7; i++)
            {
                sched.SetStartTime(i, g11a, new TimeSpan(8, 0, 0));
                sched.SetStartTime(i, g11g, new TimeSpan(9, 35, 0));
            }
            sched[0][g11a] = new ObservableCollection<Class>();
            sched[0][g11g] = new ObservableCollection<Class>();

            sched[0][g11a].Add(tp11a);//11A class has TP from 8AM to 9:20AM in room 32 on monday
            sched[0][g11g].Add(tp11g);//11G class has TP from 9:35AM to 10:55AM in room 24 on monday
            //result should be false as professor day conflict
            TimeSpan start = new TimeSpan(9, 30, 0);
            TimeSpan end = new TimeSpan(16, 20, 0);
            List<TimeDayRequirement> prevents = new List<TimeDayRequirement>();
            TimeDayRequirement aPrevent = new TimeDayRequirement(mitov, 0, start, end);
            prevents.Add(aPrevent);
            s.Start();
            IConstraint c = new ProfessorDayAndTimeConstraint(prevents);
            var result = c.Check(sched);
            s.Stop();

            string pass = result.ConstraintFulfilled == false ? "succeeded" : "failed";
            Console.WriteLine("TestProfessorDayAndTimeConstraint() " + pass);
            Console.WriteLine(result.ErrorMessage);
            Console.WriteLine("{0} ms.", s.ElapsedMilliseconds);
        }
Ejemplo n.º 8
0
 public void SetStartTime(int aDay, StudentGroup aGroup, TimeSpan aStartTime)
 {
     if (aDay >= startTimes.Length || aDay < 0)
         throw new ArgumentOutOfRangeException("aDay", "Day should be between 0 and 6");
     if (startTimes[aDay].ContainsKey(aGroup))
     {
         startTimes[aDay][aGroup] = aStartTime;
     }
     else
     {
         startTimes[aDay].Add(aGroup, aStartTime);
     }
 }