(* This file defines objects and operation related to class scheduling. See Sections 2.4 and 2.6 of the Milestone 4 requirements. Module ScheduledClass defines the objects and operations related to scheduling Classes. *) module ScheduledClass; from Time import all; from Database import all; from ScheduleM import all; export all; object ScheduledClass is components: c:course and i:Instructor and r:Room and s:SectionNumber and startTime:TimePeriod and endTime:TimePeriod; description: (*A scheduled class has a course, instructor, a room, a section , a starting time, and an ending time.*); end ScheduledClass; operation ScheduleClass is inputs: sc:ScheduledClass, s:Schedule; outputs:s':Schedule; description: (*The Schedule Class operation takes all of the inputs in the manual scheduling of a class and adds it to the ScheduledClasses in the Schedule.*); precondition:(* The start time, is before the end time. Which means the starting * hour is before the ending hour. The hours are also, 0 - 23. The minutes are *only 0 - 59. Instructor has to exist in the database. The course exists in the *database. The room exists in the database. There are no other classes *scheduled in the same room and in conflicting time periods. The instructor is not teaching another class at the same time. *) sc.c in s.cd and sc.i in s.id and sc.r in s.rd and (sc.startTime.h.i < 24 and sc.startTime.h.i > 0 and sc.startTime.m.i > 0 and sc.startTime.m.i < 60 and sc.endTime.h.i > 0 and sc.endTime.h.i < 24 and sc.endTime.m.i > 0 and sc.endTime.m.i < 60) and (sc.startTime.h < sc.endTime.h) or (sc.startTime.m < sc.endTime.m) and not (exists (sc' in s.scheduledClasses ) sc'.r = sc.r and ((sc'.endTime.h.i <= sc.startTime.h.i) or (sc'.startTime.h.i >= sc.endTime.h.i))) and not (exists (sc' in s.scheduledClasses) sc'.i = sc.i and (sc'.endTime.h.i <= sc.startTime.h.i or sc'.startTime.h.i >= sc.endTime.h.i)); postcondition: (* The Scheduled Class is in the ScheduledClassList and nothing else is changed.*) forall (sc':ScheduledClass) (sc' in s'.scheduledClasses) iff ((sc' = sc) or (sc' in s.scheduledClasses)); end ScheduleClass; end ScheduledClass;