Bertl sammelt Beeper und fährt die anzahl der Beeper nach oben und fährt zum Ausgangspunkt.
Fork of While_Task3 by
main.cpp@1:d8c1ed589950, 2015-05-08 (annotated)
- Committer:
- DoTTi
- Date:
- Fri May 08 09:19:03 2015 +0000
- Revision:
- 1:d8c1ed589950
- Parent:
- 0:27a5933a5e04
Bertl sammelt Beeper und f?hrt die anzahl der Beeper nach oben und f?hrt zum Ausgangspunkt.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DoTTi | 1:d8c1ed589950 | 1 | /** Beschreibung |
DoTTi | 1:d8c1ed589950 | 2 | */ |
DoTTi | 1:d8c1ed589950 | 3 | |
martinale | 0:27a5933a5e04 | 4 | #include "mbed.h" |
martinale | 0:27a5933a5e04 | 5 | #include "Robot.h" |
martinale | 0:27a5933a5e04 | 6 | #include "const.h" |
martinale | 0:27a5933a5e04 | 7 | |
DoTTi | 1:d8c1ed589950 | 8 | int Beeper=0; |
DoTTi | 1:d8c1ed589950 | 9 | int move=0; |
DoTTi | 1:d8c1ed589950 | 10 | |
DoTTi | 1:d8c1ed589950 | 11 | class Bertl_Beeper : public Bertl |
martinale | 0:27a5933a5e04 | 12 | { |
martinale | 0:27a5933a5e04 | 13 | public: |
DoTTi | 1:d8c1ed589950 | 14 | void PickAllBeeperToTheWall(); |
martinale | 0:27a5933a5e04 | 15 | }; |
martinale | 0:27a5933a5e04 | 16 | |
DoTTi | 1:d8c1ed589950 | 17 | void Bertl_Beeper :: PickAllBeeperToTheWall() |
martinale | 0:27a5933a5e04 | 18 | { |
martinale | 0:27a5933a5e04 | 19 | while(FrontIsClear()) |
martinale | 0:27a5933a5e04 | 20 | { |
martinale | 0:27a5933a5e04 | 21 | if(NextToABeeper()) |
martinale | 0:27a5933a5e04 | 22 | { |
martinale | 0:27a5933a5e04 | 23 | PickBeeper(); |
DoTTi | 1:d8c1ed589950 | 24 | Beeper++; |
martinale | 0:27a5933a5e04 | 25 | NibbleLeds(AnyBeeperInBag()); |
martinale | 0:27a5933a5e04 | 26 | wait(1); |
martinale | 0:27a5933a5e04 | 27 | Move(); |
martinale | 0:27a5933a5e04 | 28 | } else |
martinale | 0:27a5933a5e04 | 29 | Move(); |
DoTTi | 1:d8c1ed589950 | 30 | move++; |
martinale | 0:27a5933a5e04 | 31 | } |
martinale | 0:27a5933a5e04 | 32 | } |
martinale | 0:27a5933a5e04 | 33 | |
martinale | 0:27a5933a5e04 | 34 | int main() |
martinale | 0:27a5933a5e04 | 35 | { |
martinale | 0:27a5933a5e04 | 36 | Bertl_Beeper karel; |
martinale | 0:27a5933a5e04 | 37 | |
martinale | 0:27a5933a5e04 | 38 | while(1) |
martinale | 0:27a5933a5e04 | 39 | { |
DoTTi | 1:d8c1ed589950 | 40 | karel.PickAllBeeperToTheWall(); |
martinale | 0:27a5933a5e04 | 41 | while(!karel.FrontIsClear()) |
martinale | 0:27a5933a5e04 | 42 | { |
DoTTi | 1:d8c1ed589950 | 43 | karel.TurnLeft(); |
martinale | 0:27a5933a5e04 | 44 | break; |
martinale | 0:27a5933a5e04 | 45 | } |
DoTTi | 1:d8c1ed589950 | 46 | break; |
martinale | 0:27a5933a5e04 | 47 | } |
DoTTi | 1:d8c1ed589950 | 48 | for(int a=0; a<=Beeper;a++) |
DoTTi | 1:d8c1ed589950 | 49 | karel.Move(Beeper); |
DoTTi | 1:d8c1ed589950 | 50 | |
DoTTi | 1:d8c1ed589950 | 51 | karel.TurnLeft(); |
DoTTi | 1:d8c1ed589950 | 52 | |
DoTTi | 1:d8c1ed589950 | 53 | for(int a=0; a<=move;a++) |
DoTTi | 1:d8c1ed589950 | 54 | karel.Move(move); |
DoTTi | 1:d8c1ed589950 | 55 | |
martinale | 0:27a5933a5e04 | 56 | } |