Thiago .
/
exercicios
exercises
Revision 0:ff7b10a0e08f, committed 2015-08-28
- Comitter:
- Jamess
- Date:
- Fri Aug 28 18:45:26 2015 +0000
- Commit message:
- Trying to learn;
Changed in this revision
diff -r 000000000000 -r ff7b10a0e08f cook.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cook.cpp Fri Aug 28 18:45:26 2015 +0000 @@ -0,0 +1,23 @@ +#include "cook.h" + +uint32_t cook::getHowWellCooks(void){ + + return howWellCooks; + + } + +void cook::setHowWellCooks(uint32_t newSkill){ + + howWellCooks = newSkill; + + } + +void cook::makeBanana(Serial* serialPort, fruits* something[]){ + + for(uint32_t i = 0;i<10;i++){ + + serialPort->printf("the number of bananas %d",something[i]->getWeight()); + wait(0.1); + + } + } \ No newline at end of file
diff -r 000000000000 -r ff7b10a0e08f cook.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cook.h Fri Aug 28 18:45:26 2015 +0000 @@ -0,0 +1,42 @@ +#ifndef COOK_H +#define COOK_H + +#include "mbed.h" +#include "fruits.h" + +class cook{ + + private: + + uint32_t howWellCooks; + /* + * A scale to know how well does the cook cooks + * 0 -> Doesnt cook at all + * ... + * 3 -> Cooks edible food + * ... + * 5 -> Me + * ... + * 10-> Master Chef + */ + + + public: + + uint32_t getHowWellCooks(void); + /* + * Returns howWellCooks + */ + void setHowWellCooks(uint32_t); + /* + * To improved or worst the cooker skill + */ + void makeBanana(Serial* ,fruits* fruit[]); + /* + * A test to see if I can pass the banana array to a function + */ + + }; + + +#endif \ No newline at end of file
diff -r 000000000000 -r ff7b10a0e08f fruits.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fruits.cpp Fri Aug 28 18:45:26 2015 +0000 @@ -0,0 +1,18 @@ +#include "fruits.h" + +fruits::fruits(){ + + weight = 10; + + } + +void fruits::setWeight(uint32_t newWeight){ + + weight= newWeight; + + } +uint32_t fruits::getWeight(void){ + + return weight; + + } \ No newline at end of file
diff -r 000000000000 -r ff7b10a0e08f fruits.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fruits.h Fri Aug 28 18:45:26 2015 +0000 @@ -0,0 +1,32 @@ +#ifndef FRUITS_H +#define FRUITS_H + +#include "mbed.h" + +class fruits{ + + private: + + uint32_t weight; + /* + */ + + public: + + + fruits(); + /** + * Default Constructor + */ + + uint32_t getWeight(void); + /** + * Returns the weight of the fruit + */ + void setWeight(uint32_t); + /** + * Sets the weight of the fruit + */ + }; + +#endif \ No newline at end of file
diff -r 000000000000 -r ff7b10a0e08f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Aug 28 18:45:26 2015 +0000 @@ -0,0 +1,32 @@ +//Aprender: +// +//ponteiro de ponteiro; +//ponteiro de ponteiro para uma classe; +//Classes dinamicamente alocadas (usando * = new) + +//static keyword; +//returning pointer;. +//virtual function; +//Criar argumentos para passar para a função criada; + +#include "mbed.h" +#include "fruits.h" +#include "cook.h" + +Serial pc(USBTX,USBRX); + +int main() { + + fruits* catpt = new fruits[10]; + fruits* pt; + pt = catpt; + + cook jarbas; + + while(1) { + + jarbas.makeBanana(&pc,&pt); + wait(0.1); + } +} +
diff -r 000000000000 -r ff7b10a0e08f mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Aug 28 18:45:26 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8ed44a420e5c \ No newline at end of file