Conceito de Classe (Private Public),

Dependencies:   mbed

Revision:
1:371785ebad41
Parent:
0:183b60b46e25
Child:
2:f8dd6b50073a
--- a/main.cpp	Tue Aug 04 13:26:00 2015 +0000
+++ b/main.cpp	Tue Aug 04 13:50:08 2015 +0000
@@ -1,3 +1,5 @@
+//Pointer to Classes
+
 #include "mbed.h"
 
 DigitalOut turnRightLed(LED1);
@@ -17,6 +19,47 @@
         void goStraight(void);
     
     };
+    
+class MotorBike{  
+    
+    private:
+        
+    uint32_t speed;
+    
+    public:
+    
+    void setSpeed(uint32_t);
+    uint32_t getSpeed(void);
+    
+    };
+        
+
+int main() {
+    
+    Car fusca;
+    MotorBike harley;
+    Car *foo;
+    foo = &fusca;
+    
+    while(1){
+        
+        fusca.turnRight();
+        wait(1);
+        fusca.goStraight();
+        wait(1);
+        fusca.turnLeft();
+        wait(2);
+        
+        foo->turnRight();
+        wait(1);
+        foo->turnLeft();
+        wait(1);
+        
+        }
+
+}
+
+/*---------FUNCTION----------*/
 
 void Car::turnRight(void){
     
@@ -39,19 +82,26 @@
     
     }
 
-int main() {
+uint32_t Car::getSpeed(void){
+    
+    return speed;
     
-    Car fusca;
+    }
+
+void Car::setSpeed(uint32_t value1){
+    
+    speed = value1;
     
-    while(1){
-        
-        fusca.turnRight();
-        wait(1);
-        fusca.goStraight();
-        wait(1);
-        fusca.turnLeft();
-        wait(1);
-        
-        }
+    }
 
-}
+void MotorBike::setSpeed(uint32_t value2){
+    
+    speed = value2;
+    
+    }
+
+uint32_t MotorBike::getSpeed(void){
+    
+    return speed;
+    
+    }
\ No newline at end of file