IV. Objects in MODSIM III
4.1 Object:
Note: object includes methods (functions) and
fields (data).
In this case field of object is hidden, it is the
value returned by method.
4.2 Capabilities:
OBJECT VehicleObject;
{ <= object declaration }
ASK METHOD
GoTo(IN destination : PositType);
BEGIN METHOD
...
executable
code goes here
...
END METHOD;
END OBJECT;
Methods ate declared along with objects and object types.
TELL METHOD Stop;
ASK object TO method ( parameter list)
or
value := ASK object TO method ( parameter list);
location := ASK SELF position( );
TELL Tiger20 TO ReportDistance(SELF);
Examples:
range := ASK SELF fuelLeft * ASK
SELF MPG;
IF ASK Tiger20 position <> HomeBase
TELL Tiger20 TO ProceedTo(HomeBase);
OUTPUT("Not
at home base, but returning");
ELSE
OUTPUT("Already at
home base");
END IF;
ASK (ASK object group) numberIn;
Example:
TYPE
{<= User defined type}
fuelType = (Unleaded,
Diesel, AvGas, JetFuel);
locationType = RECORD {<= define record}
EngineObj = OBJECT {<= define objects}
VehicleObj = OBJECT( EngineObj )
AircraftObj = OBJECT( VehicleObj )
HelicopterObj = OBJECT( AircraftObj ) { <= define inherited object}
END MODULE.
AircraftObj = OBJECT( VehicleObj
)
altitude : INTEGER;
OVERRIDE
{<= use a new definition for an object}
OBJECT AircraftObj
{<= new defintion given here for that object}
TELL METHOD Stop;
BEGIN