Class Bertl added

Dependencies:   HCSR

Dependents:   BertlDrive_V2 BertlDrive_V2

Committer:
bulmecisco
Date:
Sun Apr 26 20:04:47 2015 +0000
Revision:
12:cedc088eaf05
Parent:
8:07e55b300ff1
Class Bertl with additional Methodes added

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 }
bulmecisco 8:07e55b300ff1 39
bulmecisco 8:07e55b300ff1 40 void Robot :: pickBeeper()
bulmecisco 8:07e55b300ff1 41 {
bulmecisco 8:07e55b300ff1 42 PickBeeper();
bulmecisco 8:07e55b300ff1 43 }
bulmecisco 8:07e55b300ff1 44
bulmecisco 8:07e55b300ff1 45 void Robot :: putBeeper()
bulmecisco 8:07e55b300ff1 46 {
bulmecisco 8:07e55b300ff1 47 PutBeeper();
bulmecisco 8:07e55b300ff1 48 }
bulmecisco 8:07e55b300ff1 49
bulmecisco 8:07e55b300ff1 50 bool Robot :: frontIsClear()
bulmecisco 8:07e55b300ff1 51 {
bulmecisco 8:07e55b300ff1 52 return FrontIsClear();
bulmecisco 8:07e55b300ff1 53 }
bulmecisco 8:07e55b300ff1 54
bulmecisco 8:07e55b300ff1 55 bool Robot :: nextToABeeper() //is there one or more beepers in the same corner?
bulmecisco 8:07e55b300ff1 56 {
bulmecisco 8:07e55b300ff1 57 return NextToABeeper();
bulmecisco 8:07e55b300ff1 58 }
bulmecisco 8:07e55b300ff1 59 bool Robot :: nextToARobot() //is there another robot in the corner?
bulmecisco 8:07e55b300ff1 60 {
bulmecisco 8:07e55b300ff1 61 return false;
bulmecisco 8:07e55b300ff1 62 }
bulmecisco 8:07e55b300ff1 63 bool Robot :: facingNorth() //is the robot facing North?
bulmecisco 8:07e55b300ff1 64 {
bulmecisco 8:07e55b300ff1 65 return true;
bulmecisco 8:07e55b300ff1 66 }
bulmecisco 8:07e55b300ff1 67 bool Robot :: facingSouth() // is the robot facing South?
bulmecisco 8:07e55b300ff1 68 {
bulmecisco 8:07e55b300ff1 69 return true;
bulmecisco 8:07e55b300ff1 70 }
bulmecisco 8:07e55b300ff1 71 bool Robot :: facingEast() // is the robot facing East?
bulmecisco 8:07e55b300ff1 72 {
bulmecisco 8:07e55b300ff1 73 return true;
bulmecisco 8:07e55b300ff1 74 }
bulmecisco 8:07e55b300ff1 75 bool Robot :: facingWest() // is the robot facing West?
bulmecisco 8:07e55b300ff1 76 {
bulmecisco 8:07e55b300ff1 77 return true;
bulmecisco 8:07e55b300ff1 78 }
bulmecisco 8:07e55b300ff1 79 bool Robot :: anyBeepersInBeeperBag() //are there any beepers in the bag?
bulmecisco 8:07e55b300ff1 80 {
bulmecisco 8:07e55b300ff1 81 return AnyBeeperInBag();
bulmecisco 8:07e55b300ff1 82 }