Jannis Marinitsch
/
WasZumReinschreiben
Bertl fährt und zählt Beeper
Meine Programme
neue Zeile = \ \
Bertl fährt und zählt beeper
main.cpp
void main() { urBertl karel; int beeper = 0; while(karel.FrontIsClear) { while(!karel.NextToABeeper()) { karel.Move(); } beeper++; bt.print("Beeper: %d", beeper); karel.Move(); } karel.TurnLeft(); for(int a = 0; a < beeper; a++) karel.Move(); karel.TurnLeft(); }
Diff: main.cpp
- Revision:
- 0:2db4b2b9cf3c
diff -r 000000000000 -r 2db4b2b9cf3c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 07 12:11:42 2015 +0000 @@ -0,0 +1,74 @@ +#include "mbed.h" +#include "ur_Bertl.h" +#include "const.h" + +void main() +{ + urBertl karel; + int beeper = 0; + + while(karel.FrontIsClear) + { + while(!karel.NextToABeeper()) + { + karel.Move(); + } + beeper++; + karel.Move(); + } + + karel.TurnLeft(); + + for(int a = 0; a < beeper; a++) + karel.Move(); + + karel.TurnLeft(); +} + +/*Serial bt(p9, p10); + +void main() +{ + int xy = 5; + + while(true) + { + bt.print("Hello Bertl: %d \n", xy); + wait(1); + } +} + +class Bertl : public ur_Bertl +{public: + void ClearAllBeepersToTheWall(); +}; + +void Bertl :: ClearAllBeepersToTheWall() +{ + while(FrontIsClear()) + { + Move(); + PickBeeper(); + } +} + +int main() +{ + Bertl karel; + + karel.ClearAllBeepersToTheWall(); + + while(!karel.NextToABeeper()) + { + karel.Move(); + } + karel.PickBeeper(); + + if ( !karel.NextToABeeper()) + karel.Move(); + if ( !karel.NextToABeeper()) + karel.Move(); + if ( !karel.NextToABeeper()) + karel.Move(); + karel.PickBeeper(); +}*/ \ No newline at end of file