Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/VDM/VDMRT/RobotRT/   (Wiener Entwicklungsmethode ©)  Datei vom 13.4.2020 mit Größe 1 kB image not shown  

Quelle  MovingObstacle.vdmrt   Sprache: VDM

 
class MovingObstacle
types
public MoveDirection = <North> | <South> | <East> | <West>;
instance variables
firstpos : Grid`Point;
pos : Grid`Point;
direction : MoveDirection;
steps :int;
busy: bool := true;
operations
 public MovingObstacle: Grid`Point * MoveDirection ==> MovingObstacle
 MovingObstacle (p, dir) ==
 (
   firstpos:=p;
   pos:= firstpos;
   direction := dir;
   steps :=0;
 );
 
 private Step : () ==> ()
 Step() ==
 duration(1000)
 (
   if steps = 10 then
     (
       SetPos(firstpos,0);
     )
   else
     (
        if direction = <North> then
          SetPos(mk_Grid`Point(pos.X,pos.Y+1),steps+1);
      
        if direction = <South> then
          SetPos(mk_Grid`Point(pos.X,pos.Y-1),steps+1);
 
        if direction = <East> then
          SetPos(mk_Grid`Point(pos.X+1,pos.Y),steps+1);
 
        if direction = <West> then
          SetPos(mk_Grid`Point(pos.X-1,pos.Y),steps+1);
 
      );
--Util`PrintDebug("Mobs");
--Util`PrintValue(pos);
 
 );
 private SetPos: Grid`Point * int ==> ()
 SetPos(p,s) == ( pos:= p; steps:= s;);
 
 public GetPos: () ==> Grid`Point
   GetPos() ==
     return pos;
 
 public Stop: () ==> ()
 Stop() == busy:=false;
thread
periodic(1000E6,100, 100,0)(Step);
 
sync
 
mutex(SetPos, GetPos);
mutex(SetPos);
 
 
end MovingObstacle



class MovingObstacleTest is subclass of TestCase
values
 
operations
 protected SetUp: () ==> ()
 SetUp () == skip;
 
 protected RunTest: () ==> ()
 RunTest () == skip;
 
  protected TearDown: () ==> ()
 TearDown () == skip
 
end MovingObstacleTest

Messung V0.5
C=92 H=98 G=94

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

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 und die Messung sind noch experimentell.