Thiago .
/
OOP_Exercise
Conceito de Classe (Private Public),
Diff: main.cpp
- Revision:
- 2:f8dd6b50073a
- Parent:
- 1:371785ebad41
--- a/main.cpp Tue Aug 04 13:50:08 2015 +0000 +++ b/main.cpp Tue Aug 04 14:14:54 2015 +0000 @@ -1,46 +1,12 @@ //Pointer to Classes #include "mbed.h" - -DigitalOut turnRightLed(LED1); -DigitalOut turnLeftLed(LED3); - -class Car{ - - private: - uint32_t speed; - - public: - uint32_t getSpeed(void); - void setSpeed(uint32_t); - - void turnRight(void); - void turnLeft(void); - void goStraight(void); - - }; - -class MotorBike{ - - private: - - uint32_t speed; - - public: - - void setSpeed(uint32_t); - uint32_t getSpeed(void); - - }; - +#include "Car.h" int main() { Car fusca; - MotorBike harley; - Car *foo; - foo = &fusca; - + while(1){ fusca.turnRight(); @@ -50,58 +16,8 @@ fusca.turnLeft(); wait(2); - foo->turnRight(); - wait(1); - foo->turnLeft(); - wait(1); - } } -/*---------FUNCTION----------*/ -void Car::turnRight(void){ - - turnRightLed = 0; - turnLeftLed = 1; - - } - -void Car::turnLeft(void){ - - turnRightLed = 1; - turnLeftLed = 0; - - } - -void Car::goStraight(void){ - - turnRightLed = 1; - turnLeftLed = 1; - - } - -uint32_t Car::getSpeed(void){ - - return speed; - - } - -void Car::setSpeed(uint32_t value1){ - - speed = value1; - - } - -void MotorBike::setSpeed(uint32_t value2){ - - speed = value2; - - } - -uint32_t MotorBike::getSpeed(void){ - - return speed; - - } \ No newline at end of file