Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:aad2349101de, committed 2019-12-22
- Comitter:
- briceetpapaul
- Date:
- Sun Dec 22 11:13:35 2019 +0000
- Commit message:
- fiin
Changed in this revision
Random.cpp | Show annotated file Show diff for this revision Revisions of this file |
Random.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r aad2349101de Random.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Random.cpp Sun Dec 22 11:13:35 2019 +0000 @@ -0,0 +1,29 @@ +#include "Random.h" + +Random::Random() +{ + srand (time(NULL)); +} + +Random::Random(int16_t limiteH, int16_t limiteB) +{ + srand (time(NULL)); + _limiteH = limiteH; + _limiteB = limiteB; +} + +void Random::changerLimiteH(int16_t limiteH) +{ + _limiteH = limiteH; +} + +void Random::changerLimiteB(int16_t limiteB) +{ + _limiteB = limiteB; +} + +int16_t Random::obtenirRandom() +{ + int16_t temp = rand() % (_limiteH + _limiteB) - _limiteB; + return temp; +} \ No newline at end of file
diff -r 000000000000 -r aad2349101de Random.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Random.h Sun Dec 22 11:13:35 2019 +0000 @@ -0,0 +1,22 @@ +#ifndef RANDOM_H +#define RANDOM_H + +#include <stdlib.h> +#include <time.h> +#include "mbed.h" + +class Random +{ + public: + Random(); + Random(int16_t limiteH, int16_t limiteB); + void changerLimiteH(int16_t limiteH); + void changerLimiteB(int16_t limiteB); + int16_t obtenirRandom(); + + private: + int16_t _limiteH; + int16_t _limiteB; +}; + +#endif // RANDOM_H \ No newline at end of file