(* * Author: Michael Shelley *) object PredictionItem is components: stugi:StudentGI, chg:Change; description: (* * A PredictionItem contains a boolean flag to indicate if the * score has been changed for a particular GradedItem in a * Prediction's whatif list. *); end PredictionItem; object Prediction is components: cls:Class, whatifs:PredictionItem*; description: (* * A Prediction is only associated with one Student, the Student * whose GraderID is associated with the gradebook retrieved by * the Student from the instructor. clsGIlist is the list of * GradedItems from a class and whatifs begin as the list of * Student GradedItems (StudentGI) taken from the Gradebook. *); end Prediction; object Change is boolean; object ClsPercent is integer; object Averages is integer*; operation ComputeTotal is description: (* * Compute the total of a Graded Item. *); inputs: pred:Prediction; outputs: pred':Prediction; precondition: (* * whatifs in Prediction is not empty. *) ((#(pred.whatifs)) > 0) and (* * The value of a whatif grade entered by the user cannot exceed * the points possible for that GradedItem in the class. * *) not(pred'.cls.tot > pred.cls.tot); end ComputeTotal; operation Avg is description: (* * Computes average scores for ungraded GradedItems if the top * most parent's score (total points for a particular GradedItem * category such as "Quizes") has been changed. *); inputs: pred:Prediction; outputs: pred':Prediction; precondition: (* * whatifs in Prediction is not empty. *) ((#(pred.whatifs)) > 0) and (* * The value of a whatif grade entered by the user cannot exceed * the points possible for that GradedItem in the class. *) not(pred'.cls.tot > pred.cls.tot) and (* * A total for a GradedItem category (top level Graded * Item) has been changed. *) forall (whatgi:PredictionItem) exists (whatgi in pred.whatifs) ((whatgi.stugi.par = nil) & (whatgi.chg = true)); end Avg;