class Road
types
public RoadNumber = <R1> | <R2> | <R3> | <R4> | <R5> | <R6> | <R7> | <R8>
| <R9> | <R10> | <R11> | <R12> | <R13> |<R14> | <R15> | <R16> | <HW1>;
values
instance variables
roadNmbr : RoadNumber;
roadLength : nat;
speedlimit : nat;
wps : set of Waypoint := {};
timePenalty : nat;
inv card wps > 1;
operations
public Road : RoadNumber * set of Waypoint * nat ==> Road
Road(roadnumber, waypoints, length) ==
(
atomic
(
roadNmbr := roadnumber;
roadLength := length;
speedlimit := Config`DefaultRoadSpeedLimit;
wps := waypoints;
timePenalty := floor(length / Config`DefaultRoadSpeedLimit);
)
)
pre card waypoints > 1;
public Road : RoadNumber * set of Waypoint * nat * nat ==> Road
Road(roadnumber, waypoints, length, limit) ==
(
roadNmbr := roadnumber;
roadLength := length;
speedlimit := limit;
wps := waypoints;
--time cost of driving on the road
timePenalty := floor(roadLength / speedlimit);
)
pre card waypoints > 1;
pure public Covers : set of Waypoint ==> bool
Covers(waypoints) ==
return {w.GetId() | w in set waypoints} = {w.GetId() | w in set wps}; --does road cover the waypoints in arg
pure public GetWaypoints : () ==> set of Waypoint
GetWaypoints()==
return wps;
pure public OppositeEnd : Waypoint ==> Waypoint
OppositeEnd(wp)==
let opposite in set wps \ {wp} in return opposite
pre wp in set wps; -- if the waypoint is not found on the road
-- it may indicate that the route is not connected
-- by the same waypoint
pure public GetSpeedLimit : () ==> nat
GetSpeedLimit()==
return speedlimit;
pure public GetLength : () ==> nat
GetLength() ==
return roadLength;
pure public GetRoadNumber : () ==> RoadNumber
GetRoadNumber()==
return roadNmbr;
pure public GetTimePenalty : () ==> nat
GetTimePenalty()==
return timePenalty;
end Road
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet)
¤
|
Haftungshinweis
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.
|