FIELD field-name AS CLASS Progress.Lang.Object
|
USING Progress.Lang.*.
CLASS Main: DEFINE VARIABLE length AS DECIMAL NO-UNDO INITIAL 5.0. DEFINE VARIABLE radius AS DECIMAL NO-UNDO INITIAL 100.0. DEFINE VARIABLE width AS DECIMAL NO-UNDO INITIAL 10.0. DEFINE TEMP-TABLE myTT NO-UNDO FIELD Shape AS CLASS Object FIELD Area AS DECIMAL. CONSTRUCTOR PUBLIC Main ( ): CREATE myTT. myTT.Shape = NEW RectangleClass (width, length). CREATE myTT. myTT.Shape = NEW CircleClass (radius). FOR EACH myTT: /* Cast the field to the common shape super class, ShapeClass */ displayArea(INPUTCAST(myTT.Shape, ShapeClass), OUTPUT myTT.Area). END. END CONSTRUCTOR. METHOD PUBLIC VOID displayArea (INPUT rShape AS CLASS ShapeClass, OUTPUT dArea AS DECIMAL): dArea = rShape:calculateArea( ). MESSAGE dArea VIEW-AS ALERT-BOX. END METHOD. END CLASS. |