(* * This file defines a Late Policy and it's objects / operations *) obj LatePolicy is non:None or gd:GraceDays or de:Decay; (* For no late policy, nothing needed *) obj None is boolean; obj Penalty is integer; (* GraceDays policy *) obj GraceDays is up:UseParent and da:Days and pen:Penalty; obj UseParent is boolean; obj Days is integer; (* Decay policy *) obj Decay is min:Minutes and hr:Hours and da:Day and wk:Weeks and penal:Penalty; obj Minutes is boolean and integer; obj Hours is boolean and integer; obj Day is boolean and integer; obj Weeks is boolean and integer; (* Set GraceDays options *) operation setInheritGrace is description: (* * Sets whether to inherit policy from parent or not *); inputs: tgd:GraceDays, usp:UseParent, gi:GradedItem; outputs: tgd':GraceDays, gi':GradedItem; precondition: (* * Gracedays and UseParent and GradedItem must all exist and * the GradedItem must be using gracedays *) tgd != nil and usp !=nil and gi != nil and tgd' = gi'.lp.gd; postcondition: (* * The graded item's graceday's UseParent must be correct *) gi'.lp.gd.up = usp; end setInheritance; operation setGDays is description: (* * Sets the number of days in the GraceDays *); inputs: tgd:GraceDays, d:Days; outputs: tgd':GraceDays; precondition: (* * tgd and d must both exist *) tgd != nil and d != nil; postcondition: (* * tgd' must contain the correct days *) tgd'.da = d; end setGDays; operation setGPenalty is description: (* * Sets the penalty in the GraceDays *); inputs: tgd:GraceDays, p:Penalty; outputs: tgd':GraceDays; precondition: (* * tgd and p must both exist *) tgd != nil and p != nil; postcondition: (* * tgd' must contain the correct penalty *) tgd'.pen = p; end setGPenlaty; (* Set decay options *) operation setDMinutes description: (* * Sets the minutes field of a decay policy *); inputs: dec:Decay, m:Minutes; outputs: dec':Decay; precondition: (* * Decay and Minutes must both exist *) dec != nil and m != nil; postcondition: (* * Decay must contain the correct minutes *) dec'.min = m; end setDMinutes; operation setDhours is description: (* * Sets the hours field of a decay policy *); inputs: dec:Decay, h:Hours; outputs: dec':Decay; precondition: (* * Decay and Hours must both exist *) dec != nil and h != nil; postcondition: (* * Decay must contain the correct Hours *) dec'.hr = h; end setDHours; operation setDWeeks description: (* * Sets the weeks field of a decay policy *); inputs: dec:Decay, w:Weeks; outputs: dec':Decay; precondition: (* * Decay and Weeks must both exist *) dec != nil and w != nil; postcondition: (* * Decay must contain the correct weeks *) dec'.wk = w; end setDMinutes; operation setDDay description: (* * Sets the Day field of a decay policy *); inputs: dec:Decay, d:Day; outputs: dec':Decay; precondition: (* * Decay and Day must both exist *) dec != nil and d != nil; postcondition: (* * Decay must contain the correct minutes *) dec'.da = d; end setDDay;