This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
in204:tds:sujets:td1:part1 [2019/09/23 15:54] bmonsuez [Question n°3] |
in204:tds:sujets:td1:part1 [2022/11/18 10:50] (current) |
||
---|---|---|---|
Line 3: | Line 3: | ||
[[in204:tds:sujets:td1|TD1]] | [[in204:tds:sujets:td1|TD1]] | ||
- | ==== Question n° 0 ==== | + | ==== Etape 0 : Installation de l'environnement ==== |
- | Lancer votre environnement de développement préféré. | + | En vous référant à la [[::in202::outils|documentation disponible]] sous ce lien et en n'hésitant pas à demander à l'enseignant de vous accompagner, installer un environnement de développement sur votre ordinateur. |
==== Question n°1 ==== | ==== Question n°1 ==== | ||
Line 46: | Line 46: | ||
}; | }; | ||
</code> | </code> | ||
+ | |||
+ | <hidden Correction> | ||
+ | |||
+ | Le fichier ''counter.hpp'' contient a priori le code suivant : | ||
+ | |||
+ | <code cpp> | ||
+ | #ifndef counterHPP | ||
+ | #define counterHPP | ||
+ | |||
+ | struct MyCounter | ||
+ | { | ||
+ | unsigned counter; | ||
+ | unsigned max; | ||
+ | |||
+ | unsigned getCounter() const { | ||
+ | return counter; | ||
+ | } | ||
+ | unsigned getMax() const { | ||
+ | return max; | ||
+ | } | ||
+ | |||
+ | void increment() { | ||
+ | counter ++; | ||
+ | if(counter > max) | ||
+ | counter = 0; | ||
+ | } | ||
+ | |||
+ | void reset() { | ||
+ | counter = 0; | ||
+ | } | ||
+ | |||
+ | void set(unsigned value) { | ||
+ | counter = (value <= max) ? value : counter; | ||
+ | } | ||
+ | |||
+ | void setMax(unsigned value) { | ||
+ | if(counter >= value) | ||
+ | counter = 0; | ||
+ | max = value;; | ||
+ | } | ||
+ | }; | ||
+ | |||
+ | #endif | ||
+ | </code> | ||
+ | |||
+ | Le fichier ''counter.cpp'' soit ne contient rien, soit se limite à incluer le fichier ''counter.hpp'' comme suit: | ||
+ | |||
+ | <code cpp> | ||
+ | |||
+ | #include"counter.hpp" | ||
+ | |||
+ | </code> | ||
+ | |||
==== Question n°2 ==== | ==== Question n°2 ==== |