Bertl

Dependencies:   HCSR

Fork of Bertl by Franz Pucher

Committer:
Michi_Jocham
Date:
Mon Dec 21 14:29:01 2015 +0000
Revision:
18:2a4fa405eec6
Parent:
8:07e55b300ff1
Bertl

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bulmecisco 8:07e55b300ff1 1 /***********************************
bulmecisco 8:07e55b300ff1 2 name: Robot.cpp Version: 1.0
bulmecisco 8:07e55b300ff1 3 author: PE HTL BULME
bulmecisco 8:07e55b300ff1 4 email: pe@bulme.at
bulmecisco 8:07e55b300ff1 5 WIKI: https://developer.mbed.org/teams/BERTL_CHEL_18/code/ur_Bertl/
bulmecisco 8:07e55b300ff1 6 description:
bulmecisco 8:07e55b300ff1 7 Implementation Robot for objectivRobot
bulmecisco 8:07e55b300ff1 8
bulmecisco 8:07e55b300ff1 9 The following lines have to be added or changed to the *.kpp file:
bulmecisco 8:07e55b300ff1 10
bulmecisco 8:07e55b300ff1 11 #include "Robot.h"
bulmecisco 8:07e55b300ff1 12 #include "mbed.h"
bulmecisco 8:07e55b300ff1 13 #include "const.h"
bulmecisco 8:07e55b300ff1 14
bulmecisco 8:07e55b300ff1 15 class Bertl : public Robot // public
bulmecisco 8:07e55b300ff1 16 {
bulmecisco 8:07e55b300ff1 17 public:
bulmecisco 8:07e55b300ff1 18 Bertl(int x, int y, int d, int b){}; // dumy constrctor with same name as the class name
bulmecisco 8:07e55b300ff1 19
bulmecisco 8:07e55b300ff1 20 rest as in KPP-file:
bulmecisco 8:07e55b300ff1 21 see in objectBertl/projects/L1_Ex1.KPP
bulmecisco 8:07e55b300ff1 22
bulmecisco 8:07e55b300ff1 23 ***********************************/
bulmecisco 8:07e55b300ff1 24 #include "mbed.h"
bulmecisco 8:07e55b300ff1 25 #include "Robot.h"
bulmecisco 8:07e55b300ff1 26 #include "ur_Bertl.h"
bulmecisco 8:07e55b300ff1 27
bulmecisco 8:07e55b300ff1 28 //Robot::Robot(int x, int y, char[] dir, int beeper) : ur_Robot(){}
bulmecisco 8:07e55b300ff1 29
bulmecisco 8:07e55b300ff1 30 void Robot :: move() // Definieren
bulmecisco 8:07e55b300ff1 31 {
bulmecisco 8:07e55b300ff1 32 Move();
bulmecisco 8:07e55b300ff1 33 }
bulmecisco 8:07e55b300ff1 34
bulmecisco 8:07e55b300ff1 35 void Robot :: turnLeft()
bulmecisco 8:07e55b300ff1 36 {
bulmecisco 8:07e55b300ff1 37 TurnLeft();
bulmecisco 8:07e55b300ff1 38 }
Michi_Jocham 18:2a4fa405eec6 39 void Robot :: turnRight()
Michi_Jocham 18:2a4fa405eec6 40 {
Michi_Jocham 18:2a4fa405eec6 41 TurnRigth();
Michi_Jocham 18:2a4fa405eec6 42 }
bulmecisco 8:07e55b300ff1 43 void Robot :: pickBeeper()
bulmecisco 8:07e55b300ff1 44 {
bulmecisco 8:07e55b300ff1 45 PickBeeper();
bulmecisco 8:07e55b300ff1 46 }
bulmecisco 8:07e55b300ff1 47
bulmecisco 8:07e55b300ff1 48 void Robot :: putBeeper()
bulmecisco 8:07e55b300ff1 49 {
bulmecisco 8:07e55b300ff1 50 PutBeeper();
bulmecisco 8:07e55b300ff1 51 }
bulmecisco 8:07e55b300ff1 52
bulmecisco 8:07e55b300ff1 53 bool Robot :: frontIsClear()
bulmecisco 8:07e55b300ff1 54 {
bulmecisco 8:07e55b300ff1 55 return FrontIsClear();
bulmecisco 8:07e55b300ff1 56 }
bulmecisco 8:07e55b300ff1 57
bulmecisco 8:07e55b300ff1 58 bool Robot :: nextToABeeper() //is there one or more beepers in the same corner?
bulmecisco 8:07e55b300ff1 59 {
bulmecisco 8:07e55b300ff1 60 return NextToABeeper();
bulmecisco 8:07e55b300ff1 61 }
bulmecisco 8:07e55b300ff1 62 bool Robot :: nextToARobot() //is there another robot in the corner?
bulmecisco 8:07e55b300ff1 63 {
bulmecisco 8:07e55b300ff1 64 return false;
bulmecisco 8:07e55b300ff1 65 }
bulmecisco 8:07e55b300ff1 66 bool Robot :: facingNorth() //is the robot facing North?
bulmecisco 8:07e55b300ff1 67 {
bulmecisco 8:07e55b300ff1 68 return true;
bulmecisco 8:07e55b300ff1 69 }
bulmecisco 8:07e55b300ff1 70 bool Robot :: facingSouth() // is the robot facing South?
bulmecisco 8:07e55b300ff1 71 {
bulmecisco 8:07e55b300ff1 72 return true;
bulmecisco 8:07e55b300ff1 73 }
bulmecisco 8:07e55b300ff1 74 bool Robot :: facingEast() // is the robot facing East?
bulmecisco 8:07e55b300ff1 75 {
bulmecisco 8:07e55b300ff1 76 return true;
bulmecisco 8:07e55b300ff1 77 }
bulmecisco 8:07e55b300ff1 78 bool Robot :: facingWest() // is the robot facing West?
bulmecisco 8:07e55b300ff1 79 {
bulmecisco 8:07e55b300ff1 80 return true;
bulmecisco 8:07e55b300ff1 81 }
bulmecisco 8:07e55b300ff1 82 bool Robot :: anyBeepersInBeeperBag() //are there any beepers in the bag?
bulmecisco 8:07e55b300ff1 83 {
bulmecisco 8:07e55b300ff1 84 return AnyBeeperInBag();
bulmecisco 8:07e55b300ff1 85 }