Bertl sammelt Beeper und fährt die anzahl der Beeper nach oben und fährt zum Ausgangspunkt.
Fork of While_Task3 by
Diff: main.cpp
- Revision:
- 1:d8c1ed589950
- Parent:
- 0:27a5933a5e04
diff -r 27a5933a5e04 -r d8c1ed589950 main.cpp --- a/main.cpp Fri Apr 24 08:44:37 2015 +0000 +++ b/main.cpp Fri May 08 09:19:03 2015 +0000 @@ -1,32 +1,33 @@ +/** Beschreibung +*/ + #include "mbed.h" #include "Robot.h" #include "const.h" -class Bertl_Beeper : public Robot +int Beeper=0; +int move=0; + +class Bertl_Beeper : public Bertl { public: - void ClearAllBeeperToTheWall(); - void TurnAround(); + void PickAllBeeperToTheWall(); }; -void Bertl_Beeper :: TurnAround() -{ - TurnLeft(); - TurnLeft(); -} - -void Bertl_Beeper :: ClearAllBeeperToTheWall() +void Bertl_Beeper :: PickAllBeeperToTheWall() { while(FrontIsClear()) { if(NextToABeeper()) { PickBeeper(); + Beeper++; NibbleLeds(AnyBeeperInBag()); wait(1); Move(); } else Move(); + move++; } } @@ -36,11 +37,20 @@ while(1) { - karel.ClearAllBeeperToTheWall(); + karel.PickAllBeeperToTheWall(); while(!karel.FrontIsClear()) { - karel.TurnAround(); + karel.TurnLeft(); break; } + break; } + for(int a=0; a<=Beeper;a++) + karel.Move(Beeper); + + karel.TurnLeft(); + + for(int a=0; a<=move;a++) + karel.Move(move); + } \ No newline at end of file