(* * This file deines the objects and operations * of a Graded Item *) obj GradedItem is name:Title and we:Weight and al:Access and pt:Points and lp:LatePolicy and par:Parent and nts:Notes and chi:Children; obj Title is string; obj Weight is integer; obj Access is string; obj Points is integer; obj Parent is string; obj Priority is integer; obj Children is GradedItem*; obj GradedItemList is GradedItem*; operation newGradedItem is description: (* * This operation creates a new GradedItem in the current class * and adds it to the GradedItemList. *); inputs: gi:GradedItem, gil:GradedItemList; outputs: gil':GradedItemList; precondition: (* * The GradedItemList must not already contain a GradedItem with the same Title * and the GradedItem must have a Title and Access *) not( exists (g:GradedItem) exists(g in gil') g.name =gi.name ) and gi.name != nil and gi.al != nil; postcondition: (* * The new GradedItem must exist in the GradedItemList *) exists (g:GradedItem) exists(g in gil') g.name = gi.name; end newGradedItem; operation delGradedItem is description: (* * This removes a graded item from the current classes GradedItemList. *); inputs: gil:GradedItemList, gi:GradedItem; outputs: gil':GradedItemList; precondition: (* * The GradedItem must already exist in the list *) exists(g:GradedItem) exists(g in gil') g.name = gi.name; postcondition: (* * The GradedItem must no longer exist in the list *) not( exists (g:GradedItem) exists(g in gil') g.name = gi.name) ; end delGradedItem; (* * Individual Item options *) operation setParentItem is description: (* * Sets the parent item of a GradedItem *); inputs: pgi:GradedItem, gi:GradedItem; outputs: gi':GradedItem, pgi':GradedItem; precondition: (* * Both the parent and the child items must exist and have (unique) titles *) pgi != nil and gi != nil and pgi.name != gi.name; postcondition: (* * The child's parent must be the parent item * and the parent must have the child *) gi'.par = pgi'.name and exists(g:GradedItem) exists(g in pgi'.chi) g.name = gi'.name; end setParentItem; operation setWeight is description: (* * Sets the weight in a GradedItem *); inputs: gi:GradedItem, w:Weight; outputs: gi':GradedItem; precondition: (* * The GradedItem must exist, and the weight must exist *) gi != nil and w != nil; postcondition: (* * The GradedItem must contain the new weight. *) gi'.we = w; end setWeight; operation setAccess is description: (* * Sets the access level of a GradedItem *); inputs: gi:GradedItem, acl:Access; outputs: gi':GradedItem; precondition: (* * The GradedItem and Access must both exist *) gi != nil and acl != nil; postcondition: (* * The GradedItem must contain the correct Access *) gi'.al = acl; end setAccess; operation setLatePolicy is description: (* * Sets the LatePolicy for a graded item *); inputs: gi:GradedItem, lap:LatePolicy; outputs: gi':GradedItem; precondition: (* * Both the GradedItem and LatePolicy must exist *) gi != nil and lap != nil; postcondition: (* * The GradedItem must containt the correct late policy *) gi'.lp = lap; end setLatePolicy; operation setNotes is description: (* * Sets the notes field of a GradedItem *); inputs: gi:GradedItem, n:Notes; outputs: gi':GradedItem; precondition: (* * Both the GradedItem and notes must exist *) gi != nil and n != nil; postcondition: (* * The GradedItem must containt the correct notes *) gi'.nts = n; end setNotes;