(**** * * This file defines the objects and operations related to maintaining the * Course database of the Scheduler Tool. * * See Section 2.5.2 of the requirements document. *) (* Objects and operations for the course database: *) module CourseDB; export CourseDB, CourseRecord, Department, CourseNumber, CourseName, WTUs, SCUs, Component; obj CourseDB is components: cr:CourseRecord*; description: (* The overall database object, which is populated with individual course records. *); end CourseDB; obj CourseRecord is components: dept:Department and cnum:CourseNumber and cname:CourseName and RequestedFeature* and PreReqs and CoReqs and PrefNumOfStudents and wtu:WTUs and scu:SCUs and cp: Component; description: (* The object which contains the information about a particular course. *); end CourseRecord; obj Department is components: string; description: (* The acronym for the Department through which the course is offered. *); end Department; obj CourseNumber is components: integer; description: (* The number descriptor that the offering department has assigned to the course, e.g 101. *); end CourseNumber; obj CourseName is components: string; description: (* The name and/or subject of the course, as assigned by the university. *); end CourseName; obj Component is components: Lecture or Lab; description: (* Each course offering at the university has a Lecture/Activity or Lab component associated with it; a CourseRecord is a record for one of these components. As such, the combination of Department, CourseName, and Component should be unique. *); end Component; obj Lecture description: (* This is just to denote that this CourseRecord is a Lecture component. *); end Lecture; obj Lab description: (* This is just to denote that this CourseRecord is a Lab component. *); end Lab; obj RequestedFeature is components: fn:FeatureName and fa:FeatureAmt; description: (* An item needed by a course, which should exist in whatever room it is assigned to. *); end RequestedFeature; obj FeatureName is components: string (*not perfectly accurate*); description: (* The name of the a feature requested by a course *); end FeatureName; obj FeatureAmt is components: integer; description: (* The requested count of items corresponding to FeatureName *); end FeatureAmt; obj PreReqs is components: string*; description:(* The department acronym and course number--space delimited--associated with the prerequisites for the course; *); end PreReqs; obj CoReqs is components: string*; description:(* The department acronym and course number--space delimited--associated with the co-requisites for the course; *); end CoReqs; obj PrefNumOfStudents is components: integer; description:(* The preferred number of students in each section of this course. *); end PrefNumOfStudents; obj WTUs is components: integer; description: (* The Weighted Teaching Units associated with teaching a section of this course *); end WTUs; obj SCUs is components: integer; description: (* The Student Course Units associated with completing a section of this course as a student *); end SCUs; obj valid is components: boolean; description: (* A boolean for use with testing certain preconditions and postconditions *); end valid; op AddCourseRecord is inputs: cdb:CourseDB, cr:CourseRecord; outputs: cdb':CourseDB; description: (* Adds exactly (no more and no less) the CourseRecord information input by the Scheduling Administrator into a new CourseRecord in the Course Database. It also does not remove or change any previous CourseRecords or the data in them. If the CourseRecord is not unique, it calls ChangeCourseRecord on the new data instead *); pre: isUnique(cr); post: ; end AddCourseRecord; op DeleteCourseRecord is inputs: cdb:CourseDB, cr:CourseRecord; outputs: cdb':CourseDB; description: (* Only (no more, no less) removes the selected CourseRecord from the CourseDB, popping up a confirmation window to confirm that this is what the Scheduling Administrator desires. *); pre: ; post: ; end DeleteCourseRecord; op ChangeCourseRecord is inputs: cdb:CourseDB, cr:CourseRecord, cr':CourseRecord; outputs: cdb':CourseDB; description: (* If and only if an old CourseRecord has been selected and new data exists in one or more of the CourseRecord fields, this operation only (no more and no less) replaces the old CourseRecord selected by the Scheduling Administrator with the new CourseRecord containing the new data. *); pre: (cr in cdb); post: isUnique(cr); end ChangeCourseRecord; function isUnique is inputs: cr:CourseRecord; outputs: valid; description: (* Checks to see if the combination of Department, CourseNumber, and Component is unique. If so, valid is set to true. Otherwise, valid is set to false. *); pre: ; post: ; end isUnique; function validAmt is inputs: rf:RequestedFeature; outputs: valid; description: (* Checks to see if the FeatureAmt of a RequestedFeature is greater than 0. If so, valid is set to true and the RequestedFeature is saved. Otherwise, valid is set to false and the RequestedFeature is removed. *); pre: ; post: ; end validAmt; end CourseDB;