Superclass Reference

A method can refer to a member of its superclass by using the %Super system variable. This construction is needed only to access superclass members that are hidden by overriding members in the current class.

In the following example, the classes that extend the general BuildingAsset class each have their own method DisasterPrep, that does the specific processing, then calls the superclass (generic) version of DisasterPrep.

/* generic building class */
class BuildingAsset
   method Acquire();
   method DisasterPrep();
end-class;

method Acquire
   %This.DisasterPrep();
end-method;method DisasterPrep
   PrepareForFire();
end-method;

/* building in Vancouver */
class VancouverBuilding extends BuildingAssetmethod DisasterPrep();
end-class;

method DisasterPrep
   PrepareForEarthquake();%Super.DisasterPrep(); /* call superclass method */
end-method;

/* building in Edmonton */
class EdmontonBuilding extends BuildingAssetmethod DisasterPrep();
end-class;

method DisasterPrep
   PrepareForFreezing();%Super.DisasterPrep(); /* call superclass method */
end-method;

local BuildingAsset &Building = Create VancouverBuilding();

&Building.Acquire(); /* calls PrepareForEarthquake then PrepareForFire */

&Building = Create EdmontonBuilding();

&Building.Acquire(); /* calls PrepareForFreezing then PrepareForFire */