5.4. Course.rsl

module CourseModule;
from ScheduleModule import Schedule;
export Course;


object CourseDB is
	components: crs:Course*;
	operations: addCourse, changeCourse, removeCourse;
	description: (*
		The CourseDB is the repository of Courses
	*);
end CourseDB;

object Course is 
	components: 
		dept:Department and cNum:CourseNumber and sec:Sections and unit:Units and len:Length 
		and conflict:Conflict* and lab:Lab*;
	operations: addCourseConflict, removeCourseConflict;
	description: (*
		A Course contains information about a particular course 
		including its name number of sections units and length as well
		as anything special about it for example labs and conflicting
		courses
	*);
end Course;

object Department is string;
object CourseNumber is integer;
object Sections is integer;
object Units is integer;
object Lab is Length and Options;
object Options is Multimedia and OS and Database and AI and Networks and Other;
object Multimedia is boolean;
object OS is boolean;
object Database is boolean;
object AI is boolean;
object Networks is boolean;
object Other is check and text;
object check is boolean;
object text is string;
object Conflict is 
	components: 
		cdept:ConflictDepartment and ccn:ConflictCourseNumber;
	description: (*
		A Conflict contains the department and Course number of a class 
		the user does not want scheduled at the same time
	*);
end Conflict;

object ConflictDepartment is string;
object ConflictCourseNumber is integer;

object Length is 
	components: Hours, Minutes;
	description: (*
		Time is in Hours and Minutes
	*);
end Length;

object Hours is integer;
object Minutes is integer;

operation AddCourse is 
	inputs: c:Course, cdb:CourseDB;
	outputs: cdb':CourseDB;
	precondition:  (*
			* There is no Course with the same Department and CourseNumber 
			* as the course to be added
			*)
			(not (exists (c' in cdb)((c'.dept = c.dept) and (c'.cNum = c.cNum))))
			
			and
			
		       (*
			* The Department is not nil and 3 chars long
			*)
			(c.dept != nil) and (#(c.dept) = 3)

			and 

		       (*
			* The Course number is not nill and is between 100 and 599
			*)
			(c.cNum != nil) and ((c.cNum >= 100) and (c.cNum < 600));			

	postcondition: (*
			* The given Course is in the output CourseDB iff it is the new one or was 
			* already in the CourseDB
			* )
			forall(c':Course)
				(c' in cdb') iff ((c' = c) or (c' in cdb));
			
	description: (*
		AddCourse adds the particular course to the course database, 
		producing an updated course database
	*);
end AddCourse;

operation ChangeCourse is
	inputs: newC:Course, oldC:Course, cdb:CourseDB;
	outputs: cdb':CourseDB;
	precondition:  (*
			* The old and new Courses are not the same
			*)
			(oldC != newC)
			
			and

		       (*
			* The old Course is in the CourseDB
			*)
			(oldC in cdb)

			and


		       (*
			* Ther is no Course with the same Dept and Course # 
			* as the new Course
			*)

			(not (exists (newC' in cdb)((newC'.dept = newC.dept) and (newC'.cNum = newC.cNum))))
			
			and
			
		       (*
			* The Department is not nil and 3 chars long
			*)
			(newC.dept != nil) and (#(newC.dept) = 3)

			and 

		       (*
			* The Course number is not nill and is between 100 and 599
			*)
			(newC.cNum != nil) and ((newC.cNum >= 100) and (newC.cNum < 600));
			
	
	postcondition: (* 
			* A Course is in the output db iff it is the new record to be added
			* or it was already there and not the same as the old Course
			*)
			forall (c' in cdb')
				(c' in cdb') iff (((c' = newC) or (c' in cdb)) and 
							(c' != oldC));	
	description: (*
		Change a course that is already in the database
	*);
end ChangeCourse;

operation RemoveCourse is 
	inputs: c:Course, cdb:CourseDB;
	outputs: cdb':CourseDB;
	precondition:  (*
			* The Course is in the Database
			*)
			(c in cdb);
	
	postcondition: (*
			* A Course is in output DB only if it is not the input Course 
			* and if it in the input DB
			*)
			(forall (c':Course)
				(c' in cdb') iff ((c' != c) and (c' in cdb)));
	description: (*
		RemoveCourse removes the particular course to the course database, 
		producing an updated course database
	*);
end RemoveCourse;

operation AddCourseConflict is 
	inputs: c:Course, con:Conflict, cdb:CourseDB;
	outputs: c':Course;
	precondition:  (*
			* The Conflict is not already listed 
			*
			* and
		        *
			* The Conflicting course is in the CourseDB
			*)
			
		       (*
			* The Conflict Department is not nil and 3 chars long
			*)
			(con.cdept != nil) and (#(con.cdept) = 3)

			and 

		       (*
			* The Conflict Course number is not nill and is between 100 and 599
			*)
			(con.ccn != nil) and ((con.ccn >= 100) and (con.ccn < 600));

	postcondition: (*
			* The Conflict course is in the Course
			*
			 forall (con':c)
				(con' in c'.conflict) iff ((con' = con) or (con' in c));
			*);
	description: (*
		AddCourseConflict adds a conflict to the course then, producing an 
		updated course
	*);
end AddCourseConflict;

operation RemoveCourseConflict is 
	inputs: Course, Conflict;
	outputs: Course;
	precondition: (*Coming Soon*);
	postcondition: (*Coming Soon*);
	description: (*
		RemoveCourseConflict adds a conflict to the course then, producing 
		an updated course
	*);
end RemoveCourseConflict;

object LocalCourse inherits from Course
	components: 
		cu:CourseUsed and cs:CourseSchedule;
	description: (*
		A CourseRoom is all the things the room is and if it is being used.
	*);
end LocalCourse;

object CourseUsed is boolean;
object CourseSchedule inherits from Schedule;
end CourseModule;
module CourseModule;

export CourseDB;
export Course;

object CourseDB is
	components: crs:Course*;
	operations: addCourse, changeCourse, removeCourse;
	description: (*
		The CourseDB is the repository of Courses
	*);
end CourseDB;

object Course is 
	components: 
		dept:Department and cNum:CourseNumber and sec:Sections and Units and Length 
		and Conflict* and Lab*;
	operations: addCourseConflict, removeCourseConflict;
	description: (*
		A Course contains information about a particular course 
		including its name number of sections units and length as well
		as anything special about it for example labs and conflicting
		courses
	*);
end Course;

object Department is string;
object CourseNumber is integer;
object Sections is integer;
object Units is integer;
object Lab is Length and Options;
object Options is Multimedia and OS and Database and AI and Networks and Other;
object Multimedia is boolean;
object OS is boolean;
object Database is boolean;
object AI is boolean;
object Networks is boolean;
object Other is check and text;
object check is boolean;
object text is string;
object Conflict is 
	components: 
		cdept:ConflictDepartment and ccn:ConflictCourseNumber;
	description: (*
		A Conflict contains the department and Course number of a class 
		the user does not want scheduled at the same time
	*);
end Conflict;

object ConflictDepartment is string;
object ConflictCourseNumber is integer;

object Length is 
	components: Hours, Minutes;
	description: (*
		Time is in Hours and Minutes
	*);
end Length;

object Hours is integer;
object Minutes is integer;

operation AddCourse is 
	inputs: c:Course, cdb:CourseDB;
	outputs: cdb':CourseDB;
	precondition:  (*
			* There is no Course with the same Department and CourseNumber 
			* as the course to be added
			*)

			(not (exists (c' in cdb)((c'.dept = c.dept) and (c'.cNum = c.cNum))))			

			and			

		       (*
			* The Department is not nil and 3 chars long
			*)
			(c.dept != nil) and (#(c.dept) = 3)

			and 

		       (*
			* The Course number is not nill and is between 100 and 599
			*)
			(c.cNum != nil) and ((c.cNum >= 100) and (c.cNum < 600));	

	postcondition: (*
			* The given Course is in the output CourseDB iff it is the new one or was 
			* already in the CourseDB
			* )
			forall(c':Course)
				(c' in cdb') iff ((c' = c) or (c' in cdb));			

	description: (*
		AddCourse adds the particular course to the course database, 
		producing an updated course database
	*);
end AddCourse;

operation ChangeCourse is
	inputs: newC:Course, oldC:Course, cdb:CourseDB;
	outputs: cdb':CourseDB;
	precondition:  (*
			* The old and new Courses are not the same
			*)
			(oldC != newC)			

			and

		       (*
			* The old Course is in the CourseDB
			*)
			(oldC in cdb)

			and

		       (*
			* Ther is no Course with the same Dept and Course # 
			* as the new Course
			*)

			(not (exists (newC' in cdb)((newC'.dept = newC.dept) and (newC'.cNum = newC.cNum))))
	

			and			

		       (*
			* The Department is not nil and 3 chars long
			*)
			(newC.dept != nil) and (#(newC.dept) = 3)

			and 

		       (*
			* The Course number is not nill and is between 100 and 599
			*)
			(newC.cNum != nil) and ((newC.cNum >= 100) and (newC.cNum < 600));	

	postcondition: (* 
			* A Course is in the output db iff it is the new record to be added
			* or it was already there and not the same as the old Course
			*)

			forall (c' in cdb')
				(c' in cdb') iff (((c' = newC) or (c' in cdb)) and 
							(c' != oldC));	
	description: (*
		Change a course that is already in the database
	*);
end ChangeCourse;

operation RemoveCourse is 
	inputs: c:Course, cdb:CourseDB;
	outputs: cdb':CourseDB;
	precondition:  (*
			* The Course is in the Database
			*)

			(c in cdb);	

	postcondition: (*
			* A Course is in output DB only if it is not the input Course 
			* and if it in the input DB
			*)

			(forall (c':Course)
				(c' in cdb') iff ((c' != c) and (c' in cdb)));
	description: (*
		RemoveCourse removes the particular course to the course database, 
		producing an updated course database
	*);
end RemoveCourse;

operation AddCourseConflict is 
	inputs: c:Course, con:Conflict, cdb:CourseDB;
	outputs: c':Course;
	precondition:  (*
			* The Conflict is not already listed 
			*
			* and
		        *
			* The Conflicting course is in the CourseDB
			*)			

		       (*
			* The Conflict Department is not nil and 3 chars long
			*)

			(con.cdept != nil) and (#(con.cdept) = 3)

			and 

		       (*
			* The Conflict Course number is not nill and is between 100 and 599
			*)
			(con.ccn != nil) and ((con.ccn >= 100) and (con.ccn < 600));

	postcondition: (*
			* The Conflict course is in the Course
			*
			* forall (con':c)
			*	(con' in c') iff ((con' = con) or (con' in c));
			*);

	description: (*
		AddCourseConflict adds a conflict to the course then, producing an 
		updated course
	*);

end AddCourseConflict;

operation RemoveCourseConflict is 
	inputs: Course, Conflict;
	outputs: Course;
	precondition: (*Coming Soon*);
	postcondition: (*Coming Soon*);
	description: (*
		RemoveCourseConflict adds a conflict to the course then, producing 
		an updated course
	*);
end RemoveCourseConflict;

object LocalCourse inherits from Course
	components: 
		CourseUsed;
	description: (*
		A CourseRoom is all the things the room is and if it is being used.
	*);
end LocalCourse;

object CourseUsed is boolean;

end CourseModule;





Prev: Instructor Listing | Next: Room Listing | Up: Specification | Top: index