obj StudentGI is sc:Score and par:SGIParent;


obj Score is integer;
obj SGIParent is GradedItem;


operation setScore is
	description:
		(*
		 * Sets a students score for a particular graded item
		 *);

	inputs: stu:Student, sgi:StudentGI, sco:Score;
	outputs: sgi':StudentGI;

	precondition:
		(*
		 * The student must contain the SGI,
		 * and both the student and the SGI must exit
		 *)
		
		stu != nil and sgi != nil and sco != nil

		and
		
		exists(tsgi:StudentGI)
		  exists(tsgi in stu.gilist)
		    tsgi = sgi;

	postcondition:
		(*
		 * The resulting SGI must contain the correct score
		 * and the new SGI must be in the student list
		 * and the old SGI must NOT be in the student list
		 *)

		
		 sgi'.sc = sgi.sc

		 and
		
		 exists(tsgi:StudentGI)
		  exists(tsgi in stu.gilist)
		    tsgi = sgi'

		and

		not(exists(tsgi:StudentGI)
		  exists(tsgi in stu.gilist)
		    tsgi = sgi');

end setScore;


operation setParent is
	description:
		(*
		 * Sets the parent field of a SGI
		 *);

	inputs: stu:Student, sgi:StudentGI, p:SGIParent;
	outputs: sgi':StudentGI;

	precondition:
		(*
		 * The inputs must exist, and the Student must contain the SGI
		 *)

		stu != nil and sgi != nil and p != nil

		and
	
		exists(tsgi:StudentGI)
		  exists(tsgi in stu.gilist)
		    tsgi = sgi;

	postcondition:
		(*
		 * The resulting SGI must contain the correct parent
		 * and the new SGI must be in the student list,
		 * and the old SGI must NOT be in the student list
		 *)

		sgi'.par = p

		and

		exists(tsgi:StudentGI)
		  exists(tsgi in stu.gilist)
		    tsgi = sgi'

		and

		not(exists(tsgi:StudentGI)
		  exists(tsgi in stu.gilist)
		    tsgi = sgi');

end setParent;