diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 35eb1dd..13aec3e 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,5 +2,6 @@ + \ No newline at end of file diff --git a/Algo/Cours/Cpp/Cpp1.jpg b/Algo/Cours/Cpp/Cpp1.jpg new file mode 100644 index 0000000..01adf09 Binary files /dev/null and b/Algo/Cours/Cpp/Cpp1.jpg differ diff --git a/Algo/Cours/Cpp/Cpp2.jpg b/Algo/Cours/Cpp/Cpp2.jpg new file mode 100644 index 0000000..cf4423f Binary files /dev/null and b/Algo/Cours/Cpp/Cpp2.jpg differ diff --git a/Algo/tp/Cpp/3.5_tp/Makefile b/Algo/tp/Cpp/3.5_tp/Makefile new file mode 100644 index 0000000..88f4002 --- /dev/null +++ b/Algo/tp/Cpp/3.5_tp/Makefile @@ -0,0 +1,26 @@ +#CC : le compilateur à utiliser +CC=g++ + +#CFLAGS : les options de compilation +CFLAGS= -std=c++17 -Wall + +# les fichiers sources : tous les fichiers présents dans src/ +SRC=$(wildcard src/*.cpp) + +# les fichiers objets (.o) +OBJ=$(patsubst src/%.cpp,obj/%.o,$(SRC)) + + +#edition des liens : génération de l'exécutable à partir des .o +bin/exe: $(OBJ) + $(CC) $(OBJ) -o $@ + +# génération des .o à partir des .cpp et .hpp crrespondants : +obj/%.o: src/%.cpp + $(CC) $(CFLAGS) -c $< -o $@ + +#nettoyage : destruction des .o et de l'exécutable +clean: + rm obj/*.o bin/exe + + diff --git a/Algo/tp/Cpp/3.5_tp/src/carte.cpp b/Algo/tp/Cpp/3.5_tp/src/carte.cpp new file mode 100644 index 0000000..d819e54 --- /dev/null +++ b/Algo/tp/Cpp/3.5_tp/src/carte.cpp @@ -0,0 +1,10 @@ +#include "carte.hpp" + +#include + + +using namespace std; + +Carte::Carte(Nom nom, Couleur couleur) + : nom{nom}, couleur{couleur} +{} diff --git a/Algo/tp/Cpp/3.5_tp/src/carte.hpp b/Algo/tp/Cpp/3.5_tp/src/carte.hpp new file mode 100644 index 0000000..a855a8e --- /dev/null +++ b/Algo/tp/Cpp/3.5_tp/src/carte.hpp @@ -0,0 +1,38 @@ +#ifndef CARTE_HPP +#define CARTE_HPP + +#include + +enum class Couleur { + BLEU, + ROUGE, + VERT, + ROSE, + JAUNE, + ORANGE, + NOIR +}; + +enum class Nom { + ROI, + RENNE, + CAVALIER, + DRAGON, + ENCHANTEUR, + MOINE, + PAYSAN, + SORCIER +}; + +class Carte { + + Nom nom; + Couleur couleur; + +public: + + Carte(Nom nom, Couleur couleur); + +}; + +#endif // CARTE_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/3.5_tp/src/jeu.cpp b/Algo/tp/Cpp/3.5_tp/src/jeu.cpp new file mode 100644 index 0000000..f3b585d --- /dev/null +++ b/Algo/tp/Cpp/3.5_tp/src/jeu.cpp @@ -0,0 +1,17 @@ +// #include "jeu.hpp" + +// #include + + +// using namespace std; + +// Jeu::Jeu() +// : +// {} + + +// ostream &operator<<(ostream &os, const Jeu &j) { + +// return os; +// } + diff --git a/Algo/tp/Cpp/3.5_tp/src/jeu.hpp b/Algo/tp/Cpp/3.5_tp/src/jeu.hpp new file mode 100644 index 0000000..4221b1e --- /dev/null +++ b/Algo/tp/Cpp/3.5_tp/src/jeu.hpp @@ -0,0 +1,17 @@ +// #ifndef JEU_HPP +// #define JEU_HPP + +// #include + +// class Jeu { + +// public: +// Jeu(); + +// friend std::ostream &operator<<(ostream &os, const Jeu &j); + +// ~Jeu()=default; + +// }; + +// #endif // JEU_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/3.5_tp/src/joueur.cpp b/Algo/tp/Cpp/3.5_tp/src/joueur.cpp new file mode 100644 index 0000000..ec0a10c --- /dev/null +++ b/Algo/tp/Cpp/3.5_tp/src/joueur.cpp @@ -0,0 +1,17 @@ +#include "joueur.hpp" + +#include + + +using namespace std; + +Joueur::Joueur(string pseudo) + : pseudo{pseudo} +{} + + +ostream &operator<<(ostream &os, const Joueur &j) { + + return os; +} + diff --git a/Algo/tp/Cpp/3.5_tp/src/joueur.hpp b/Algo/tp/Cpp/3.5_tp/src/joueur.hpp new file mode 100644 index 0000000..ff41642 --- /dev/null +++ b/Algo/tp/Cpp/3.5_tp/src/joueur.hpp @@ -0,0 +1,27 @@ +#ifndef JOUEUR_HPP +#define JOUEUR_HPP + +#include +#include +#include "carte.hpp" + +class Joueur { + + std::string pseudo; + list lesCartes; + +public: + + Joueur(std::string pseudo); + + std::string getPseudo(); + + Carte donnerCarte(int num); + bool recevoirCarte(Carte c); + void prendreCarte(Joueur j); + + ~Joueur()=default; + +}; + +#endif // JOUEUR_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/3.5_tp/src/main.cpp b/Algo/tp/Cpp/3.5_tp/src/main.cpp new file mode 100644 index 0000000..d2ae415 --- /dev/null +++ b/Algo/tp/Cpp/3.5_tp/src/main.cpp @@ -0,0 +1,7 @@ + + + +int main() { + +return 0; +} \ No newline at end of file diff --git a/Algo/tp/Cpp/3.5_tp/tp4_sorcierNoir.pdf b/Algo/tp/Cpp/3.5_tp/tp4_sorcierNoir.pdf new file mode 100644 index 0000000..30dbd35 Binary files /dev/null and b/Algo/tp/Cpp/3.5_tp/tp4_sorcierNoir.pdf differ diff --git a/Algo/tp/Cpp/4_tp/bin/exe b/Algo/tp/Cpp/4_tp/bin/exe deleted file mode 100755 index d8c8091..0000000 Binary files a/Algo/tp/Cpp/4_tp/bin/exe and /dev/null differ diff --git a/Algo/tp/Cpp/4_tp/src/livreRecettes.cpp b/Algo/tp/Cpp/4_tp/src/livreRecettes.cpp index 8e1cfae..e8dd411 100644 --- a/Algo/tp/Cpp/4_tp/src/livreRecettes.cpp +++ b/Algo/tp/Cpp/4_tp/src/livreRecettes.cpp @@ -1,29 +1,67 @@ #include "livreRecettes.hpp" +#include "recetteAffichage.hpp" +#include "ingredient.hpp" +#include +#include using namespace std; namespace appli { - // map> LivreRecettes::rechercherRecette(const string &nomRecette) { - // for(auto it = ) - // } + map> LivreRecettes::rechercherRecette(const string &nomRecette) { + map> rech; + for(auto it = livre.cbegin(); it != livre.cend(); ++it) { + if(it->first.getNom() == nomRecette) { + rech.insert({it->first, it->second}); + } + } + return rech; + } map LivreRecettes::faireListeCourses(list l) { + string nomRecette; + int rep; + + cout << "Quelle recette voulez vous ? " << endl; + cin >> nomRecette; + map>::iterator it = livre.find(nomRecette); + // it = this->rechercherRecette(nomRecette); + for(const Ingredient &ing : it->second) { + cout << "avez vous du, des " << ing << " ? (0 : non/1 : oui)" << endl; + cin >> rep; + if(rep == 0) { + l.push_back(ing); + } + } } void LivreRecettes::ajouter(const Recette &r, list l) { - - l.push_back(r) - ajouter dans le livre la rec + unordered_set ing; + if(livre.find(r) != livre.end()) { + cout << "recette déjà présente" << endl; + return; + } + for(Ingredient i : l) { + unordered_set::iterator it2 = ing.find(i); + if(it2 == ing.end()) { + ing.insert(i); + } + else { + Quantite q = i.getQuantite() + it2->getQuantite(); + ing.erase(it2); + ing.insert(Ingredient{i.getAliment(), q}); + } + } + livre.insert({r, ing}); } void LivreRecettes::afficherNomRecette() { - + afficherNoms(livre); } void LivreRecettes::afficher() { - + afficherTout(livre); } } \ No newline at end of file diff --git a/Algo/tp/Cpp/4_tp/src/livreRecettes.hpp b/Algo/tp/Cpp/4_tp/src/livreRecettes.hpp index bb97859..820c7c4 100644 --- a/Algo/tp/Cpp/4_tp/src/livreRecettes.hpp +++ b/Algo/tp/Cpp/4_tp/src/livreRecettes.hpp @@ -11,7 +11,7 @@ namespace appli { class LivreRecettes { - std::list livre; + std::map> livre; public: diff --git a/Algo/tp/Cpp/4_tp/src/main.cpp b/Algo/tp/Cpp/4_tp/src/main.cpp index cd61b21..dfd5255 100644 --- a/Algo/tp/Cpp/4_tp/src/main.cpp +++ b/Algo/tp/Cpp/4_tp/src/main.cpp @@ -6,6 +6,7 @@ #include"ingredient.hpp" #include"recette.hpp" #include"recetteAffichage.hpp" +#include "livreRecettes.hpp" using namespace std; @@ -121,14 +122,37 @@ void testLivreRecettes(){ cout << " testLivreRecettes() " << endl; cout << "------------------------------" << endl; + // appli::Recette r{"Soupe de poireaux", "Faire cuire les légumes puis mixer."}; + + // unordered_set ing; + // ing.insert(appli::Ingredient{"poireaux", appli::Quantite{2, appli::Unite::UNITE}}); + // ing.insert(appli::Ingredient{"pommes de terre", appli::Quantite{300, appli::Unite::G}}); + // ing.insert(appli::Ingredient{"eau", appli::Quantite{50, appli::Unite::CL}}); + + // appli::Recette r2{"Crêpes", "Faire fondre le beurre. Mélanger la farine, le sel et le sucre. Y ajouter les oeufs puis le lait et enfin le beurre fondu. Faire cuire à la poêle quelques minutes de chaque côté."}; + + // unordered_set ing2; + // ing2.insert(appli::Ingredient{"farine", appli::Quantite{250, appli::Unite::G}}); + // ing2.insert(appli::Ingredient{"lait", appli::Quantite{0.5, appli::Unite::L}}); + // ing2.insert(appli::Ingredient{"sucre", appli::Quantite{30, appli::Unite::G}}); + // ing2.insert(appli::Ingredient{"oeufs", appli::Quantite{4, appli::Unite::UNITE}}); + // ing2.insert(appli::Ingredient{"sel", appli::Quantite{3, appli::Unite::G}}); + // ing2.insert(appli::Ingredient{"beurre", appli::Quantite{50, appli::Unite::G}}); + + // map> livre; + + // appli::LivreRecettes::ajouter(r, ing); + // appli::LivreRecettes::ajouter(r2, ing2); + + // livre.appli::LivreRecette::afficherNomRecette() //à compléter } int main(){ - // testUnite(); - // testQuantite(); - // testIngredient(); + testUnite(); + testQuantite(); + testIngredient(); testRecette(); // testLivreRecettes(); diff --git a/Algo/tp/Cpp/4_tp/src/unite.cpp b/Algo/tp/Cpp/4_tp/src/unite.cpp index b5ad3c3..39d8fc3 100644 --- a/Algo/tp/Cpp/4_tp/src/unite.cpp +++ b/Algo/tp/Cpp/4_tp/src/unite.cpp @@ -19,7 +19,7 @@ namespace appli { break; case Unite::UNITE : os << ""; break; - }; + } return os; } diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/Makefile b/Algo/tp/Cpp/4_tp_Antoine 2/Makefile new file mode 100644 index 0000000..88f4002 --- /dev/null +++ b/Algo/tp/Cpp/4_tp_Antoine 2/Makefile @@ -0,0 +1,26 @@ +#CC : le compilateur à utiliser +CC=g++ + +#CFLAGS : les options de compilation +CFLAGS= -std=c++17 -Wall + +# les fichiers sources : tous les fichiers présents dans src/ +SRC=$(wildcard src/*.cpp) + +# les fichiers objets (.o) +OBJ=$(patsubst src/%.cpp,obj/%.o,$(SRC)) + + +#edition des liens : génération de l'exécutable à partir des .o +bin/exe: $(OBJ) + $(CC) $(OBJ) -o $@ + +# génération des .o à partir des .cpp et .hpp crrespondants : +obj/%.o: src/%.cpp + $(CC) $(CFLAGS) -c $< -o $@ + +#nettoyage : destruction des .o et de l'exécutable +clean: + rm obj/*.o bin/exe + + diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/bin/exe b/Algo/tp/Cpp/4_tp_Antoine 2/bin/exe new file mode 100755 index 0000000..53e5d61 Binary files /dev/null and b/Algo/tp/Cpp/4_tp_Antoine 2/bin/exe differ diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/src/ingredient.cpp b/Algo/tp/Cpp/4_tp_Antoine 2/src/ingredient.cpp new file mode 100644 index 0000000..469527a --- /dev/null +++ b/Algo/tp/Cpp/4_tp_Antoine 2/src/ingredient.cpp @@ -0,0 +1,30 @@ +#include "ingredient.hpp" +#include "quantite.hpp" + + +using namespace std; + +namespace appli { + + Ingredient::Ingredient(const string &aliment, const Quantite &quantite) + : aliment{aliment}, quantite{quantite} + {} + + string Ingredient::getAliment() const { + return aliment; + } + + Quantite Ingredient::getQuantite() const { + return quantite; + } + + ostream &operator<<(ostream &os, const Ingredient &i) { + os << i.getQuantite() << " " << i.getAliment() << endl; + return os; + } + + bool operator==(const Ingredient &i1, const Ingredient &i2) { + return(i1.getAliment() == i2.getAliment()); + } + +} \ No newline at end of file diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/src/ingredient.hpp b/Algo/tp/Cpp/4_tp_Antoine 2/src/ingredient.hpp new file mode 100644 index 0000000..98523b4 --- /dev/null +++ b/Algo/tp/Cpp/4_tp_Antoine 2/src/ingredient.hpp @@ -0,0 +1,37 @@ +#ifndef INGREDIENT_HPP +#define INGREDIENT_HPP + +#include "quantite.hpp" +#include + + +namespace appli { + + class Ingredient { + + std::string aliment; + Quantite quantite; + + public: + + Ingredient(const std::string &aliment, const Quantite &quantite); + + std::string getAliment() const; + Quantite getQuantite() const; + }; + + std::ostream &operator<<(std::ostream &os, const Ingredient &i); + bool operator==(const Ingredient &i1, const Ingredient &i2); + +} + +namespace std { + template <> + struct hash { + size_t operator()(const appli::Ingredient &i) const { + return hash()(i.getAliment()); + } + }; +} + +#endif //INGREDIENT_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/src/livreRecettes.cpp b/Algo/tp/Cpp/4_tp_Antoine 2/src/livreRecettes.cpp new file mode 100644 index 0000000..e2f403b --- /dev/null +++ b/Algo/tp/Cpp/4_tp_Antoine 2/src/livreRecettes.cpp @@ -0,0 +1,98 @@ +#include "livreRecettes.hpp" +#include "recetteAffichage.hpp" +#include "ingredient.hpp" +#include +#include + +using namespace std; + +namespace appli { + + map> LivreRecettes::rechercherRecette(const string &nomRecette) { + map> rech; + for(auto it = livre.cbegin(); it != livre.cend(); ++it) { + if(it->first.getNom() == nomRecette) { + rech.insert({it->first, it->second}); + } + } + return rech; + } + + /* + map LivreRecettes::faireListeCourses(list l) { + string nomRecette; + int rep; + + cout << "Quelle recette voulez vous ? " << endl; + cin >> nomRecette; + map>::iterator it = livre.find(nomRecette); + // it = this->rechercherRecette(nomRecette); + + for(const Ingredient &ing : it->second) { + cout << "avez vous du, des " << ing << " ? (0 : non/1 : oui)" << endl; + cin >> rep; + if(rep == 0) { + l.push_back(ing); + } + } + } + */ + + // comme ça : on fait la liste de tous les ingrédients nécessaire pour faire les recettes choisies + // (sans prendre en compte si on possède déjà des aliments) + map LivreRecettes::faireListeCourses(list l) { + map listeDeCourses; + + // pour chaque recette de la liste de recettes que l'on souhaite réaliser : + for(const Recette & r : l){ + map>::iterator it = livre.find(r); + if(it == livre.end()) cout << "recette inconnue\n"; + else{ + for(const Ingredient &ing : it->second) { + // si l'ingrédient est déjà dans la liste de courses on met à jour sa quantité + map::iterator itIng = listeDeCourses.find(ing.getAliment()); + if(itIng !=listeDeCourses.end()){ + itIng->second = itIng->second + ing.getQuantite(); + } + else{ + // sinon on l'ajoute dans la liste de courses + listeDeCourses[ing.getAliment()] = ing.getQuantite(); + } + } + } + } + + return listeDeCourses; + } + + + + void LivreRecettes::ajouter(const Recette &r, list l) { + unordered_set ing; + if(livre.find(r) != livre.end()) { + cout << "recette déjà présente" << endl; + return; + } + for(Ingredient i : l) { + unordered_set::iterator it2 = ing.find(i); + if(it2 == ing.end()) { + ing.insert(i); + } + else { + Quantite q = i.getQuantite() + it2->getQuantite(); + ing.erase(it2); + ing.insert(Ingredient{i.getAliment(), q}); + } + } + livre.insert({r, ing}); + } + + void LivreRecettes::afficherNomRecette() { + afficherNoms(livre); + } + + void LivreRecettes::afficher() { + afficherTout(livre); + } + +} diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/src/livreRecettes.hpp b/Algo/tp/Cpp/4_tp_Antoine 2/src/livreRecettes.hpp new file mode 100644 index 0000000..820c7c4 --- /dev/null +++ b/Algo/tp/Cpp/4_tp_Antoine 2/src/livreRecettes.hpp @@ -0,0 +1,29 @@ +#ifndef LIVRERECETTES_HPP +#define LIVRERECETTES_HPP + +#include "recette.hpp" +#include "ingredient.hpp" +#include +#include +#include + +namespace appli { + + class LivreRecettes { + + std::map> livre; + + public: + + std::map> rechercherRecette(const std::string &nomRecette); + std::map faireListeCourses(std::list l); + + void ajouter(const Recette &r, std::list l); + void afficherNomRecette(); + void afficher(); + }; + +} + + +#endif // LIVRERECETTES_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/src/main.cpp b/Algo/tp/Cpp/4_tp_Antoine 2/src/main.cpp new file mode 100644 index 0000000..a1a88f3 --- /dev/null +++ b/Algo/tp/Cpp/4_tp_Antoine 2/src/main.cpp @@ -0,0 +1,177 @@ +#include +#include +#include +#include + +#include "unite.hpp" +#include "quantite.hpp" +#include "ingredient.hpp" +#include "recette.hpp" +#include "recetteAffichage.hpp" +#include "livreRecettes.hpp" + +using namespace std; + +void testUnite(){ + cout << "------------------------------" << endl; + cout << " testUnite() " << endl; + cout << "------------------------------" << endl; + + cout << "Résultat attendu => résultat" << endl; + cout << "kg => " << appli::Unite::KG << endl; + cout << "g => " << appli::Unite::G << endl; + cout << "mL => " << appli::Unite::ML << endl; + cout << "cL => " << appli::Unite::CL << endl; + cout << "dL => " << appli::Unite::DL << endl; + cout << "L => " << appli::Unite::L << endl; + cout << " => " << appli::Unite::UNITE << endl; +} + +void testQuantite(){ + cout << "------------------------------" << endl; + cout << " testQuantite() " << endl; + cout << "------------------------------" << endl; + + cout << "Résultat attendu => résultat" << endl; + cout << "1.0 => " << appli::Quantite{} << endl; + cout << "2.5 => " << appli::Quantite{2.5} << endl; + cout << "1.5L => " << appli::Quantite{1.5, appli::Unite::L} << endl; + + // Partie 3: + cout << "15L => " << appli::Quantite{15, appli::Unite::L}.normaliser() << endl; + cout << "1.5L => " << appli::Quantite{15, appli::Unite::DL}.normaliser() << endl; + cout << "0.15L => " << appli::Quantite{15, appli::Unite::CL}.normaliser() << endl; + cout << "0.015L => " << appli::Quantite{15, appli::Unite::ML}.normaliser() << endl; + cout << "15L => " << appli::Quantite{15, appli::Unite::L}.normaliser() << endl; + cout << "0.8kg => " << appli::Quantite{0.8, appli::Unite::KG}.normaliser() << endl; + cout << "0.5kg => " << appli::Quantite{500, appli::Unite::G}.normaliser() << endl; + cout << "2 => " << appli::Quantite{2, appli::Unite::UNITE}.normaliser() << endl; + + cout << "1.5kg => " << appli::Quantite{1, appli::Unite::KG}+appli::Quantite{500, appli::Unite::G} << endl; + cout << "0.75L => " << appli::Quantite{5, appli::Unite::DL}+appli::Quantite{250, appli::Unite::ML} << endl; + cout << "Détection d'erreur ?" << endl; + cout << appli::Quantite{5, appli::Unite::DL}+appli::Quantite{250, appli::Unite::G} << endl; + +} + +void testIngredient(){ + cout << "------------------------------" << endl; + cout << " testIngredient() " << endl; + cout << "------------------------------" << endl; + + appli::Ingredient i1{"poireaux", appli::Quantite{2.0, appli::Unite::UNITE}}; + appli::Ingredient i2{"pommes de terre", appli::Quantite{300, appli::Unite::G}}; + appli::Ingredient i3{"eau", appli::Quantite{50, appli::Unite::CL}}; + + cout << "Résultat attendu => résultat" << endl; + cout << "2 poireaux => " << i1 << endl; + cout << "300g pommes de terre => " << i2 << endl; + cout << "50cL eau => " << i3 << endl; + + // à compléter + +} + +void testRecette(){ + cout << "------------------------------" << endl; + cout << " testRecette() " << endl; + cout << "------------------------------" << endl; + + appli::Recette r{"Soupe de poireaux", "Faire cuire les légumes puis mixer."}; + + unordered_set ing; + ing.insert(appli::Ingredient{"poireaux", appli::Quantite{2, appli::Unite::UNITE}}); + ing.insert(appli::Ingredient{"pommes de terre", appli::Quantite{300, appli::Unite::G}}); + ing.insert(appli::Ingredient{"eau", appli::Quantite{50, appli::Unite::CL}}); + + cout << "Résultat attendu" << endl << "=>" << endl << "résultat" << endl << endl; + cout << "Soupe de poireaux\n\t300g pommes de terre\n\t50cL eau\n\t2 poireaux" << endl << "=>" << endl; + afficherNomEtIngredients(r, ing); + + cout << endl; + cout << "Soupe de poireaux\n\t300g pommes de terre\n\t50cL eau\n\t2 poireaux\ndescription :\nFaire cuire les légumes puis mixer." << endl << "=>" << endl; + afficherTout(r, ing); + + appli::Recette r2{"Crêpes", "Faire fondre le beurre. Mélanger la farine, le sel et le sucre. Y ajouter les oeufs puis le lait et enfin le beurre fondu. Faire cuire à la poêle quelques minutes de chaque côté."}; + + unordered_set ing2; + ing2.insert(appli::Ingredient{"farine", appli::Quantite{250, appli::Unite::G}}); + ing2.insert(appli::Ingredient{"lait", appli::Quantite{0.5, appli::Unite::L}}); + ing2.insert(appli::Ingredient{"sucre", appli::Quantite{30, appli::Unite::G}}); + ing2.insert(appli::Ingredient{"oeufs", appli::Quantite{4, appli::Unite::UNITE}}); + ing2.insert(appli::Ingredient{"sel", appli::Quantite{3, appli::Unite::G}}); + ing2.insert(appli::Ingredient{"beurre", appli::Quantite{50, appli::Unite::G}}); + + map> recettes; + recettes.insert(pair{r,ing}); + recettes.insert(pair{r2,ing2}); + + cout << endl; + cout << "Crêpes\n\t50g beurre\n\t3g sel\n\t4 oeufs\n\t30g sucre\n\t0.5L lait\n\t250g farine\ndescription :\nFaire fondre le beurre. Mélanger la farine, le sel et le sucre. Y ajouter les oeufs puis le lait et enfin le beurre fondu. Faire cuire à la poêle quelques minutes de chaque côté.\nSoupe de poireaux\n\t300g pommes de terre\n\t50cL eau\n\t2 poireaux\ndescription :\nFaire cuire les légumes puis mixer." << endl << "=>" << endl; + afficherTout(recettes); + + + cout << endl; + cout << "Crêpes\nSoupe de poireaux" << endl << "=>" << endl; + afficherNoms(recettes); + + +} + + +void testLivreRecettes(){ + cout << "------------------------------" << endl; + cout << " testLivreRecettes() " << endl; + cout << "------------------------------" << endl; + + appli::Recette r{"Soupe de poireaux", "Faire cuire les légumes puis mixer."}; + list ing; + ing.push_back(appli::Ingredient{"poireaux", appli::Quantite{2, appli::Unite::UNITE}}); + ing.push_back(appli::Ingredient{"pommes de terre", appli::Quantite{300, appli::Unite::G}}); + ing.push_back(appli::Ingredient{"eau", appli::Quantite{50, appli::Unite::CL}}); + + appli::Recette r1{"Soupe de poireaux", "Faire cuire les légumes et lentilles puis mixer."}; + list ing1; + ing1.push_back(appli::Ingredient{"poireaux", appli::Quantite{3, appli::Unite::UNITE}}); + ing1.push_back(appli::Ingredient{"lentilles corail", appli::Quantite{200, appli::Unite::G}}); + ing1.push_back(appli::Ingredient{"carottes", appli::Quantite{200, appli::Unite::G}}); + + appli::Recette r2{"Crêpes", "Faire fondre le beurre. Mélanger la farine, le sel et le sucre. Y ajouter les oeufs puis le lait et enfin le beurre fondu. Faire cuire à la poêle quelques minutes de chaque côté."}; + list ing2; + ing2.push_back(appli::Ingredient{"farine", appli::Quantite{250, appli::Unite::G}}); + ing2.push_back(appli::Ingredient{"lait", appli::Quantite{0.5, appli::Unite::L}}); + ing2.push_back(appli::Ingredient{"sucre", appli::Quantite{30, appli::Unite::G}}); + ing2.push_back(appli::Ingredient{"oeufs", appli::Quantite{4, appli::Unite::UNITE}}); + ing2.push_back(appli::Ingredient{"sel", appli::Quantite{3, appli::Unite::G}}); + ing2.push_back(appli::Ingredient{"beurre", appli::Quantite{50, appli::Unite::G}}); + + appli::LivreRecettes livre; + + livre.ajouter(r, ing); + livre.ajouter(r1, ing1); + livre.ajouter(r2, ing2); + + livre.afficherNomRecette(); + + cout << "--------------------------------\n"; + list listeRecettes; + listeRecettes.push_back(r); + listeRecettes.push_back(r1); + map listeDeCourses = livre.faireListeCourses(listeRecettes); + cout << "liste de courses nécessaires : \n"; + for(auto p : listeDeCourses){ + cout <<"\t" << p.first << " : " << p.second << endl; + } + + +} + +int main(){ + // testUnite(); + // testQuantite(); + // testIngredient(); + // testRecette(); + testLivreRecettes(); + + return 0; +} diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/src/quantite.cpp b/Algo/tp/Cpp/4_tp_Antoine 2/src/quantite.cpp new file mode 100644 index 0000000..8f24ca2 --- /dev/null +++ b/Algo/tp/Cpp/4_tp_Antoine 2/src/quantite.cpp @@ -0,0 +1,66 @@ +#include "quantite.hpp" +#include "unite.hpp" + +using namespace std; + +namespace appli { + + Quantite::Quantite(double nombre, const Unite &unite) + : nombre{nombre}, unite{unite} + {} + + double Quantite::getNombre() const { + return nombre; + } + + Unite Quantite::getUnite() const { + return unite; + } + + Quantite Quantite::normaliser() const { + switch(unite) { + case Unite::KG : + return *this; + break; + case Unite::G : + return Quantite{nombre / 1000,Unite::KG}; + break; + case Unite::L : + return *this; + break; + case Unite::DL : + return Quantite{nombre / 10, Unite::L}; + break; + case Unite::CL : + return Quantite{nombre / 100, Unite::L}; + break; + case Unite::ML : + return Quantite{nombre / 1000, Unite::L}; + break; + case Unite::UNITE : + return Quantite{nombre / 1, Unite::UNITE}; + break; + }; + return *this; + } + + ostream &operator<<(ostream &os, const Quantite &q) { + os << q.getNombre() << q.getUnite(); + return os; + } + + Quantite operator+(const Quantite &q1, const Quantite &q2) { + if(q1.getUnite() == q2.getUnite()) return Quantite(q1.getNombre() + q2.getNombre(), q1.getUnite()); + else { + Quantite q1bis = q1.normaliser(); + Quantite q2bis = q2.normaliser(); + if(q1bis.getUnite() == q2bis.getUnite()) + return Quantite{q1bis.getNombre() + q2bis.getNombre(), q1bis.getUnite()}; + else { + cout << "Impossible d'ajouter des unités non compatibles" << endl; + return q1; + } + } + } + +} \ No newline at end of file diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/src/quantite.hpp b/Algo/tp/Cpp/4_tp_Antoine 2/src/quantite.hpp new file mode 100644 index 0000000..b0d32e8 --- /dev/null +++ b/Algo/tp/Cpp/4_tp_Antoine 2/src/quantite.hpp @@ -0,0 +1,31 @@ +#ifndef QUANTITE_HPP +#define QUANTITE_HPP + +#include +#include "unite.hpp" + + +namespace appli { + + class Quantite { + + double nombre; + Unite unite; + + public: + + Quantite(double nombre=1, const Unite &unite=Unite::UNITE); + + Quantite normaliser() const; + + double getNombre() const; + Unite getUnite() const; + }; + + std::ostream &operator<<(std::ostream &os, const Quantite &q); + Quantite operator+(const Quantite &q1, const Quantite &q2); + +} + + +#endif // QUANTITE_HPP diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/src/recette.cpp b/Algo/tp/Cpp/4_tp_Antoine 2/src/recette.cpp new file mode 100644 index 0000000..8a8deb2 --- /dev/null +++ b/Algo/tp/Cpp/4_tp_Antoine 2/src/recette.cpp @@ -0,0 +1,28 @@ +#include "recette.hpp" + +using namespace std; + +namespace appli { + + Recette::Recette(const string &nom, const string &description) + : nom{nom}, description{description} + {} + + string Recette::getNom() const { + return nom; + } + + string Recette::getDescription() const { + return description; + } + + bool operator<(const Recette &r1, const Recette &r2) { + if(r1.getNom() < r2.getNom()) + return true; + if(r1.getNom() > r2.getNom()) + return false; + + return r1.getDescription() < r2.getDescription(); + } + +} \ No newline at end of file diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/src/recette.hpp b/Algo/tp/Cpp/4_tp_Antoine 2/src/recette.hpp new file mode 100644 index 0000000..621678c --- /dev/null +++ b/Algo/tp/Cpp/4_tp_Antoine 2/src/recette.hpp @@ -0,0 +1,29 @@ +#ifndef RECETTE_HPP +#define RECETTE_HPP + +#include +#include "ingredient.hpp" + + +namespace appli { + + class Recette { + + std::string nom; + std::string description; + + public: + + Recette(const std::string &nom, const std::string &description); + + std::string getNom() const; + std::string getDescription() const; + }; + + bool operator<(const Recette &r1, const Recette &r2); + +} + + + +#endif //RECETTE_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/src/recetteAffichage.cpp b/Algo/tp/Cpp/4_tp_Antoine 2/src/recetteAffichage.cpp new file mode 100644 index 0000000..378df16 --- /dev/null +++ b/Algo/tp/Cpp/4_tp_Antoine 2/src/recetteAffichage.cpp @@ -0,0 +1,35 @@ +#include "recetteAffichage.hpp" + + +using namespace std; +using namespace appli; + +void afficherNomEtIngredients(const Recette &r, const unordered_set &ingred) { + cout << r.getNom() << endl; + for(auto it = ingred.cbegin(); it != ingred.cend(); ++it) { + cout << "\t" << *it; + } + // for(Ingredient i : ingred) { //! OU CETTE FAÇON + // cout << i << endl; + // } +} + +void afficherTout(const Recette &r, const unordered_set &ingredient) { + cout << r.getNom() << endl; + for(auto it = ingredient.cbegin(); it != ingredient.cend(); ++it) { + cout << "\t" << *it; + } + cout << "description :\n" << r.getDescription() << endl; +} + +void afficherTout(const map> &recettes) { + for(auto it = recettes.cbegin(); it != recettes.cend(); ++it) { + afficherTout(it->first, it->second); + } +} + +void afficherNoms(const map> &recettes) { + for(map>::const_iterator it = recettes.cbegin(); it != recettes.cend(); ++it){ + cout << it->first.getNom() << endl; + } +} \ No newline at end of file diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/src/recetteAffichage.hpp b/Algo/tp/Cpp/4_tp_Antoine 2/src/recetteAffichage.hpp new file mode 100644 index 0000000..b563bdc --- /dev/null +++ b/Algo/tp/Cpp/4_tp_Antoine 2/src/recetteAffichage.hpp @@ -0,0 +1,15 @@ +#ifndef RECETTEAFFICHAGE_HPP +#define RECETTEAFFICHAGE_HPP + +#include "recette.hpp" +#include "ingredient.hpp" +#include +#include + + +void afficherNomEtIngredients(const appli::Recette &r, const std::unordered_set &ingred); +void afficherTout(const appli::Recette &r, const std::unordered_set &ingredients); +void afficherTout(const std::map> &recettes); +void afficherNoms(const std::map> &recettes); + +#endif // RECETTEAFFICHAGE_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/src/unite.cpp b/Algo/tp/Cpp/4_tp_Antoine 2/src/unite.cpp new file mode 100644 index 0000000..39d8fc3 --- /dev/null +++ b/Algo/tp/Cpp/4_tp_Antoine 2/src/unite.cpp @@ -0,0 +1,26 @@ +#include "unite.hpp" + +using namespace std; +namespace appli { + + ostream &operator<<(ostream &os, const Unite &u) { + switch(u) { + case Unite::KG : os << "kg"; + break; + case Unite::G : os << "g"; + break; + case Unite::L : os << "L"; + break; + case Unite::DL : os << "dL"; + break; + case Unite::CL : os << "cL"; + break; + case Unite::ML : os << "mL"; + break; + case Unite::UNITE : os << ""; + break; + } + return os; + } + +} \ No newline at end of file diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/src/unite.hpp b/Algo/tp/Cpp/4_tp_Antoine 2/src/unite.hpp new file mode 100644 index 0000000..3a87edc --- /dev/null +++ b/Algo/tp/Cpp/4_tp_Antoine 2/src/unite.hpp @@ -0,0 +1,14 @@ +#ifndef UNITE_HPP +#define UNITE_HPP + +#include + +namespace appli { + + enum class Unite{KG, G, L, DL, CL, ML, UNITE}; + + std::ostream &operator<<(std::ostream &os, const Unite &u); + +} + +#endif // UNITE_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/4_tp_Antoine 2/tp5_recettes.pdf b/Algo/tp/Cpp/4_tp_Antoine 2/tp5_recettes.pdf new file mode 100644 index 0000000..172e512 Binary files /dev/null and b/Algo/tp/Cpp/4_tp_Antoine 2/tp5_recettes.pdf differ diff --git a/Algo/tp/Cpp/4_tp_Antoine.zip b/Algo/tp/Cpp/4_tp_Antoine.zip new file mode 100644 index 0000000..6233cda Binary files /dev/null and b/Algo/tp/Cpp/4_tp_Antoine.zip differ diff --git a/Algo/tp/Cpp/5_tp/Makefile b/Algo/tp/Cpp/5_tp/Makefile new file mode 100644 index 0000000..88f4002 --- /dev/null +++ b/Algo/tp/Cpp/5_tp/Makefile @@ -0,0 +1,26 @@ +#CC : le compilateur à utiliser +CC=g++ + +#CFLAGS : les options de compilation +CFLAGS= -std=c++17 -Wall + +# les fichiers sources : tous les fichiers présents dans src/ +SRC=$(wildcard src/*.cpp) + +# les fichiers objets (.o) +OBJ=$(patsubst src/%.cpp,obj/%.o,$(SRC)) + + +#edition des liens : génération de l'exécutable à partir des .o +bin/exe: $(OBJ) + $(CC) $(OBJ) -o $@ + +# génération des .o à partir des .cpp et .hpp crrespondants : +obj/%.o: src/%.cpp + $(CC) $(CFLAGS) -c $< -o $@ + +#nettoyage : destruction des .o et de l'exécutable +clean: + rm obj/*.o bin/exe + + diff --git a/Algo/tp/Cpp/5_tp/TPFarwest.pdf b/Algo/tp/Cpp/5_tp/TPFarwest.pdf new file mode 100644 index 0000000..9e27534 Binary files /dev/null and b/Algo/tp/Cpp/5_tp/TPFarwest.pdf differ diff --git a/Algo/tp/Cpp/5_tp/src/barmen.cpp b/Algo/tp/Cpp/5_tp/src/barmen.cpp new file mode 100644 index 0000000..a57b51b --- /dev/null +++ b/Algo/tp/Cpp/5_tp/src/barmen.cpp @@ -0,0 +1,44 @@ +#include "barmen.hpp" + +using namespace std; + +namespace personnage { + + Barmen::Barmen(const string &nom, const string &nomBar) + : Humain(nom, "bière"), nomBar{nomBar} + {} + + Barmen::Barmen(const string &nom) + : Humain(nom, "bière"), nomBar{"Coffee Place"} + {} + + string Barmen::getNomBar() const { + return this->nomBar; + } + + void Barmen::parler(const string &texte) const { + cout << "(" << this->getNom() << ") --- " << texte << " mon gars." << endl; + } + + void Barmen::sePresenter() const { + Humain::sePresenter(); + this->parler("De plus, je possede un bar qui se nomme le " + this->getNomBar()); + } + + void Barmen::servirVerre(const Cowboy &cowboy) const { + this->parler("Et voilà pour toi " + cowboy.getNom() +"ton verre favori") + } + + void Barmen::servirVerre(const Dame &dame) const { + this->parler("Et voilà pour toi " + dame.getNom() +"ton verre favori") + } + + void Barmen::servirVerre(const Sherif &sherif) const { + this->parler("Et voilà pour toi " + sherif.getNom() +"ton verre favori") + } + + void Barmen::servirVerre(const Brigand &brigand) const { + this->parler("Et voilà pour toi " + brigand.getNom() +"ton verre favori") + } + +} \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp/src/barmen.hpp b/Algo/tp/Cpp/5_tp/src/barmen.hpp new file mode 100644 index 0000000..90ea7e9 --- /dev/null +++ b/Algo/tp/Cpp/5_tp/src/barmen.hpp @@ -0,0 +1,41 @@ +#ifndef BARMEN_HPP +#define BARMEN_HPP + +#include +#include "humain.hpp" + + +namespace personnage { + + class Dame; + + class Sherif; + + class Brigand; + + class Cowboy; + + class Barmen : public Humain { + + std::string nom; + std::string nomBar; + + public : + + Barmen(const std::string &nom); + Barmen(const std::string &nom, const std::string &nomBar); + + std::string getNomBar() const; + + void sePresenter() const override; + void parler(const std::string &texte) const override; + void servirVerre(const Cowboy &cowboy) const; + void servirVerre(const Dame &dame) const; + void servirVerre(const Sherif &sherif) const; + void servirVerre(const Brigand &brigand) const; + + }; + +} + +#endif // BARMEN_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp/src/brigand.cpp b/Algo/tp/Cpp/5_tp/src/brigand.cpp new file mode 100644 index 0000000..ef0030e --- /dev/null +++ b/Algo/tp/Cpp/5_tp/src/brigand.cpp @@ -0,0 +1,61 @@ +#include "brigand.hpp" + +#include + + +using namespace std; + +namespace personnage { + + Brigand::Brigand(const string &nom, const string &boisson, const string &comportement, const float &recompense) + : Humain(nom, boisson), comportement{comportement}, recompense{recompense} + {} + + Brigand::Brigand(const string &nom) + : Humain(nom, "tord-boyaux"), comportement{"méchant"}, recompense{100} + {} + + string Brigand::getNom() const { + return Humain::getNom() + " le " + this->comportement; + } + + float Brigand::getMiseAPrix() const { + return recompense; + } + + void Brigand::kidnapper(const Dame &dame) { + this->parler("Ah ah !" + dame.getNom() + ", tu est mienne désormais !"); + dame.seFaireKidnapper(this); + nbDamesEnlevees += 1; + } + + bool Brigand::seFaireEmprisonnerPar(const Sherif &sherif) { + this->parler("Damned, je suis fait ! " + sherif.getNom() + ", tu m'as eu !"); + enPrison = true; + } + + void Brigand::sePresenter() const { + Humain::sePresenter(); + if(this->nbDamesEnlevees > 0) { + if(this->enPrison == false) { + this->parler("Je suis " + this->comportement + ", j'ai capturé " + to_string(this->nbDamesEnlevees) + " femmes au total."); //? Comment arrondir au centieme ? + this->parler("La récompense pour ma capture est de " + to_string(this->recompense) + "$"); + } + else { + this->parler("Je suis " + this->comportement + ", j'ai capturé " + to_string(this->nbDamesEnlevees) + " femmes au total, avant d'arriver en prison."); + } + } + else { + if(this->enPrison == false) { + this->parler("Je suis " + this->comportement + ", mais je n'ai toujours pas capturé de femme à ce jour ! "); //? Comment arrondir au centieme ? + this->parler("La récompense pour ma capture est de " + to_string(this->recompense) + "$"); + } + else { + this->parler("Je suis " + this->comportement + ", mais je suis allé en prison sans avoir le temps de capturé une seule femme !"); + } + } + } + + + +} \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp/src/brigand.hpp b/Algo/tp/Cpp/5_tp/src/brigand.hpp new file mode 100644 index 0000000..ed9c32e --- /dev/null +++ b/Algo/tp/Cpp/5_tp/src/brigand.hpp @@ -0,0 +1,38 @@ +#ifndef BRIGAND_HPP +#define BRIGAND_HPP + +#include +#include "humain.hpp" + + + +namespace personnage { + + class Dame; + + class Sherif; + + class Brigand : public Humain{ + + std::string comportement; + int nbDamesEnlevees = 0; + float recompense; + bool enPrison = false; + + public: + + Brigand(const std::string &nom, const std::string &boisson, const std::string &comportement, const float &recompense); + Brigand(const std::string &nom); + + std::string getNom() const override; + float getMiseAPrix() const; + + void kidnapper(const Dame &dame); + bool seFaireEmprisonnerPar(const Sherif &sherif); + + void sePresenter() const override; + }; + +} + +#endif // BRIGAND_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp/src/cowboy.cpp b/Algo/tp/Cpp/5_tp/src/cowboy.cpp new file mode 100644 index 0000000..af30166 --- /dev/null +++ b/Algo/tp/Cpp/5_tp/src/cowboy.cpp @@ -0,0 +1,40 @@ +#include "cowboy.hpp" + +#include + + +using namespace std; + +namespace personnage { + + Cowboy::Cowboy(const string &nom, const string &boisson, const string &attitude) + : Humain(nom, boisson), attitude{attitude} + {} + + Cowboy::Cowboy(const string &nom) + : Humain(nom, "whisky"), attitude{"vaillant"} + {} + + void Cowboy::liberer(const Dame &dame) { + dame.seFaireLiberer(this); + this->parler("Que vous avez une belle robe " + dame.getCouleurRobe() + ". Elle vous vas à ravir ! ;)"); + } + + void Cowboy::tirerSur(const Brigand &brigand) { + this->narrateur("Le " + this->attitude + " " + this->getNom() + " tire sur " + brigand.getNom() + ". PAN !"); + cout << "(Le narrateur) --- Le " << this->attitude << " " << this->getNom() << " tire sur " << brigand.getNom() << ". PAN !" << endl; + this->parler("Prend ça, rascal !"); + this->liberer(); //? Comment savoir qui on doit liberer ? + } + + void Cowboy::sePresenter() const { + Humain::sePresenter(); + if(this->popularite > 0) { + this->parler("Je suis un " + this->attitude + " cowboy. De plus, j'ai une popularité grimpante de " + to_string(this->popularite) + "."); //! Quand c'est des nb, ne pas oublier de les passer en to_string ! + } + else { + this->parler("Je suis un " + this->attitude + " cowboy, mais ma popularité est encore nulle. Un jour viendras, je serais le plus grand des cowboy du comté !!"); + } + } + +} \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp/src/cowboy.hpp b/Algo/tp/Cpp/5_tp/src/cowboy.hpp new file mode 100644 index 0000000..b3f3ec2 --- /dev/null +++ b/Algo/tp/Cpp/5_tp/src/cowboy.hpp @@ -0,0 +1,31 @@ +#ifndef COWBOY_HPP +#define COWBOY_HPP + +#include +#include "humain.hpp" + +namespace personnage { + + class Dame; + + class Brigand; + + class Cowboy : public Humain { + + int popularite = 0; + std::string attitude; + + public: + + Cowboy(const std::string &nom, const std::string &boisson, const std::string &attitude); + Cowboy(const std::string &nom); + + void liberer(const Dame &dame); + void tirerSur(const Brigand &brigand); + + void sePresenter() const override; + }; + +} + +#endif // COWBOY_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp/src/dame.cpp b/Algo/tp/Cpp/5_tp/src/dame.cpp new file mode 100644 index 0000000..5043dcc --- /dev/null +++ b/Algo/tp/Cpp/5_tp/src/dame.cpp @@ -0,0 +1,54 @@ +#include "dame.hpp" + +#include + + +using namespace std; + +namespace personnage { + + Dame::Dame(const string &nom, const string &boisson, const string &couleurRobe) + : Humain(nom, boisson), couleurRobe{couleurRobe} + {} + + Dame::Dame(const string &nom) + : Humain(nom, "lait"), couleurRobe{"blanche"} + {} + + string Dame::getNom() const { + return "Miss " + Humain::getNom(); + } + + string Dame::getCouleurRobe() const { + return couleurRobe; + } + + bool Dame::isCaptive() const { + return captive; + } + + void Dame::setCouleurRobe(const string &couleur) { + this->couleurRobe = couleur; + } + + void Dame::seFaireKidnapper(const Brigand &brigand) { + cout << "Au secour, je me fait kidnapper par " << brigand.getNom() << ". Aidez moi !!!" << endl; + this->captive = true; + } + + bool Dame::seFaireLiberer(const Cowboy &cowboy) { + if(captive == false) { + cout << "Ah, Ah, Ah ! Mais pour qui vous prenez vous ?! Je suis une femme libre enfin !" << endl; + return false; + } + else { + cout << "Merci " << cowboy.getNom() << ", mon valeureux cowboy, je t'en suis reconnaissante !" << endl; + } + } + + void Dame::sePresenter() const { + Humain::sePresenter(); + this->parler( "Et j'ai une robe de couleur " + this->couleurRobe + " qui est magnifique, en plus de me mettre en valeur !"); + } + +} \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp/src/dame.hpp b/Algo/tp/Cpp/5_tp/src/dame.hpp new file mode 100644 index 0000000..96d348e --- /dev/null +++ b/Algo/tp/Cpp/5_tp/src/dame.hpp @@ -0,0 +1,38 @@ +#ifndef DAME_HPP +#define DAME_HPP + +#include +#include "humain.hpp" + +namespace personnage { + + class Brigand; + + class Cowboy; + + class Dame : public Humain { + + std::string couleurRobe; + bool captive = false; + + public: + + Dame(const std::string &nom, const std::string &boisson, const std::string &couleurRobe); + Dame(const std::string &nom); + + std::string getNom() const override; + std::string getCouleurRobe() const; + bool isCaptive() const; + + void setCouleurRobe(const std::string &couleur); + + void seFaireKidnapper(const Brigand &brigand); + bool seFaireLiberer(const Cowboy &cowboy); + + void sePresenter() const override; + + }; + +} + +#endif // DAME_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp/src/humain.cpp b/Algo/tp/Cpp/5_tp/src/humain.cpp new file mode 100644 index 0000000..93f0a67 --- /dev/null +++ b/Algo/tp/Cpp/5_tp/src/humain.cpp @@ -0,0 +1,47 @@ +#include "humain.hpp" + +#include + + +using namespace std; + +namespace personnage { + + Humain::Humain(const string &nom, const string &boisson) + : nom{nom}, boisson{boisson} + {} + + Humain::Humain(const string &nom) + : nom{nom}, boisson{"eau"} + {} + + string Humain::getNom() const { + return nom; + } + + string Humain::getBoisson() const { + return boisson; + } + + void Humain::setBoisson(const string &boisson) { + this->boisson = boisson; + } + + void Humain::parler(const string &texte) const { + cout << "(" << this->nom << ") --- " << texte << endl; + } + + void Humain::sePresenter() const { + this->parler("Bonjour, je m'appelle " + this->nom + ", ma boisson favorite est le " + this->boisson); + } + + void Humain::narrateur(const string &texte) const { + cout << "(narrateur) --- " << texte << endl; + } + + void Humain::boire() const { + cout << "Ah ! Un bon verre de " << this->boisson << " ! GLOUPS !" << endl; + } + +} + diff --git a/Algo/tp/Cpp/5_tp/src/humain.hpp b/Algo/tp/Cpp/5_tp/src/humain.hpp new file mode 100644 index 0000000..8673bae --- /dev/null +++ b/Algo/tp/Cpp/5_tp/src/humain.hpp @@ -0,0 +1,31 @@ +#ifndef HUMAIN_HPP +#define HUMAIN_HPP + +#include + +namespace personnage { + + class Humain { + + std::string nom; + std::string boisson; + + public: + + Humain(const std::string &nom, const std::string &boisson); + Humain(const std::string &nom); + + virtual std::string getNom() const; + std::string getBoisson() const; + + void setBoisson(const std::string &boisson); + + virtual void parler(const std::string &texte) const; + virtual void sePresenter() const; + void narrateur(const std::string &texte) const; + void boire() const; + }; + +} + +#endif // HUMAIN_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp/src/main.cpp b/Algo/tp/Cpp/5_tp/src/main.cpp new file mode 100644 index 0000000..84f54c0 --- /dev/null +++ b/Algo/tp/Cpp/5_tp/src/main.cpp @@ -0,0 +1,140 @@ +#include "humain.hpp" +#include "dame.hpp" +#include "brigand.hpp" +#include "cowboy.hpp" +#include "barmen.hpp" +#include "sherif.hpp" + + +using namespace std; + +void testHumain() { + personnage::Humain jacques("Jacques", "biere"); + personnage::Humain pierre("Pierre"); + pierre.setBoisson("binouse"); + jacques.sePresenter(); + pierre.sePresenter(); + jacques.boire(); + pierre.boire(); + pierre.parler("C'était bien sympa Jacques, rentrons à la maison maintenant !"); +} + +void testDame() { + personnage::Dame rose("Rose"); + personnage::Dame ginette("Ginette", "ricard", "noir"); + rose.sePresenter(); + ginette.sePresenter(); + rose.setCouleurRobe("verte"); + rose.sePresenter(); + rose.parler("J'aime les beaux cowboy !"); +} + +void testBrigand() { + personnage::Brigand robert("Robert"); + personnage::Brigand bernard("Bernard", "aveze", "ronchon", 200); + robert.sePresenter(); + bernard.sePresenter(); +} + +void testCowboy() { + personnage::Cowboy danny("Danny", "whisky", "magnifique"); + personnage::Cowboy george("George"); + danny.sePresenter(); + george.sePresenter(); +} + +void testDBHumain() { + personnage::Dame rose("Rose"); + personnage::Brigand marc("marc"); + const personnage::Humain &vilainHumain = marc; + const personnage::Humain &gentilleHumain = rose; + cout << "Je suis " << vilainHumain.getNom() << endl; + cout << "Je suis " << gentilleHumain.getNom() << endl; +} + +void testBarmen() { + personnage::Barmen jose("Jose"); + personnage::Barmen franck("Franck", "The Franchy Bar"); + jose.sePresenter(); + franck.sePresenter(); + jose.parler("J'aime les frites !!!"); +} + +void testSherif() { + personnage::Brigand robert("Robert"); + personnage::Cowboy *clint = new personnage::Sherif{"Clint"}; + clint->sePresenter(); + clint->parler("Je suis magnifique aujourd'hui. Mais comme toujours c'est vraie !"); + clint->coffrerBrigand(robert); +} + +void testGeneral() { + personnage::Humain pierre("Pierre"); + personnage::Dame rose("Rose"); + personnage::Dame ginette("Ginette", "ricard", "noir"); + personnage::Brigand robert("Robert"); + personnage::Brigand bernard("Bernard", "aveze", "ronchon", 200); + personnage::Cowboy george("George"); + personnage::Barmen franck("Franck", "The Franchy Bar"); + personnage::Sherif clint("Clint"); + personnage::Humain::narrateur("Il était une fois, une jeune et belle dame qui se promenait dans les bois avec une amie."); + rose.sePresenter(); + ginette.sePresenter(); + rose.parler("Qu'il fait beau aujourd'hui !!"); + personnage::Humain::narrateur("Tout allait bien dans le meilleur des mondes, jusqu'à ce que deux brigands apparurent."); + robert.sePresenter(); + bernard.sePresenter(); + robert.parler("Nous allons vous kidnapper pauvres dames !!"); + bernard.kidnapper(rose); + robert.kidnapper(ginette); + personnage::Humain::narrateur("Les pauvres Rose et Ginette se firent kidnapper par ses deux truans. Mais un vieux cowboy n'est pas loin"); + george.sePresenter(); + george.parler("Que faites vous bande de mal autrus !!!"); + george.tirerSur(robert); + george.tirerSur(bernard); + bernard.parler("Tu nous a loupé veillard !!"); + george.liberer(ginette); + robert.parler("À bientôt l'ancien !!"); + personnage::Humain::narrateur("Et les deux brigands pure s'en aller paisiblement car la vieux cowboy ne tiré plus tout droit."); + personnage::Humain::narrateur("Surtout avec tout l'alcool qu'il s'était enpiffré. Mais il réussi quand même à liberer une des deux filles."); + personnage::Humain::narrateur("Et notre cowboy retourna au bar pour se remettre de ses émotions."); + george.parler("Hey Franck, un verre stp pour moi et cette dame !"); + franck.servirVerre(george); + franck.servirVerre(ginette); + franck.parler("Alors ces brigands ??!!"); + george.parler("Ils se sont enfuit, j'ai plus la forme comme avant ! Mais j'ai réussi à liberer cette dame."); + personnage::Humain::narrateur("Pendant ce temps là, les brigands s'échappe toujours. Notre cowboy décide donc d'en informer le Shérif."); + george.parler("Sherif !! J'ai deux brigands qui m'on échapés."); + clint.parler("Très bien george. Repose toi ! Je prends le relais"); + clint.rechercherBrigand(bernard); + clint.rechercherBrigand(robert); + personnage::Humain::narrateur("Cela s'annonce compliqué pour notre Shérif !!"); + clint.parler("Où on-t-il bien pu partir ???"); + pierre.sePresenter(); + pierre.parler("Sherif ! J'ai vu ces deux gangster avec une très jolie femme avec eux !"); + clint.parler("Et où ça ?"); + pierre.parler("Ils sont près de la gare !!!"); + clint.parler("En avant mon fidèle destrier pilepoil !!"); + personnage::Humain::narrateur("Notre Shérif entama donc son périple vers la gare avec son cheval pile-poil."); + personnage::Humain::narrateur("Une fois arrivé, il se cacha et s'approcha discrètement de ses deux brigands avant de les intercepter."); + clint.coffrerBrigand(robert); + clint.tirerSur(bernard); + clint.coffrerBrigand(bernard); + clint.liberer(rose); + rose.parler("Mais que vous êtes merveuilleux mon shérif !!"); + clint.parler("Pour vous servir Miss rose."); + personnage::Humain::narrateur("Nos deux personnage partir tout deux heureux."); +} + + +int main() { + // testHumain(); + // testDame(); + // testBrigand(); + // testCowboy(); + // testDBHumain(); + // testBarmen(); + // testSherif(); + // testGeneral(); + return 0; +} \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp/src/sherif.cpp b/Algo/tp/Cpp/5_tp/src/sherif.cpp new file mode 100644 index 0000000..afa9191 --- /dev/null +++ b/Algo/tp/Cpp/5_tp/src/sherif.cpp @@ -0,0 +1,27 @@ +#include "sherif.hpp" + +using namespace std; + +namespace personnage { + + Sherif::Sherif(const string &nom) + : Cowboy(nom, "Tekila", "honnête") + {} + + string Sherif::getNom() const { + return "Shérif " + Cowboy::getNom(); + } + + void Sherif::coffrerBrigand(const Brigand &brigand) { + if() { //? Comment verifier s'il est en prison ? + this->parler(brigand.getNom() + " au nom de la loi, je vous arrête !!") + brigand.seFaireEmprisonerPar(this); + } + } + + void Sherif::rechercherBrigand(const Brigand &brigand) { + //? Comment l'écrire sans utiliser de find a chaque fois ? + Humain::narrateur("OYEZ OYEZ BRAVE GENS !! " + brigand.getMiseAPrix() + " $ à qui arrêtera " + brigand.getNom() + "mort ou vif !!"); + } + +} \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp/src/sherif.hpp b/Algo/tp/Cpp/5_tp/src/sherif.hpp new file mode 100644 index 0000000..58937af --- /dev/null +++ b/Algo/tp/Cpp/5_tp/src/sherif.hpp @@ -0,0 +1,30 @@ +#ifndef SHERIF_HPP +#define SHERIF_HPP + +#include +#include "cowboy.hpp" + +namespace personnage { + + class Brigand; + + class Sherif : public Cowboy { + + std::string nom; + int nbBrigands = 0; + + public : + + Sherif(const std::string &nom); + + std::string getNom() const override; + + void coffrerBrigand(const Brigand &brigand); + void rechercherBrigand(const Brigand &brigand); + + }; + +} + + +#endif // SHERIF_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp_Antoine.zip b/Algo/tp/Cpp/5_tp_Antoine.zip new file mode 100644 index 0000000..b458014 Binary files /dev/null and b/Algo/tp/Cpp/5_tp_Antoine.zip differ diff --git a/Algo/tp/Cpp/5_tp_Antoine/Adire.txt b/Algo/tp/Cpp/5_tp_Antoine/Adire.txt new file mode 100644 index 0000000..72594ee --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/Adire.txt @@ -0,0 +1,46 @@ +Bonjour Antoine, + +concernant le TP sur le western : + +de manière générale, les const, virtual et override sont bien mis. + + dans la classe Humain : + dans la méthode sePresenter : on doit faire appel à getNom() et non à l'attribut nom directement, car sinon on aura pas l'affichage voulu quand on l'appellera à partir d'un objet de classe fille. + il n'y a pas de méthode narrateur. QUand on dit dans le sujet que le narrateur dit c'est que l'on fera simplement un cout pour afficher une ligne de texte sans que ce soit un personnage qui parle. + dans boire, ce n'est pas un cout qu'il faut faire car ici c'est le personnage qui dit/parle donc on fait appel à parler pour dire la phrase voulue. + dans la classe Dame : + dans dame.cpp ne pas oublier d'inclure cowboy.hpp et brigand.hpp car on a besoin de connaître les méthodes de ces classes pour y faire appel + habituellement, quand dans un constructeur on fait appel au constructeur de la classe mère, la notation utilisée de nos jours est celle avec les {} et plus (). On écrira plutôt : + Dame::Dame(const string &nom, const string &boisson, const string &couleurRobe) + : Humain{nom, boisson}, couleurRobe{couleurRobe} + quand elle change de robe elle dit un truc d'après le sujet => donc dans setCouleurRobe ne pas oublier cette ligne + dans seFaireLiberer ne pas oublier de la libérer la dame et de retourner le bouléen qui indique que ça a été fait + dans la classe Brigand : + dans brigand.cpp ne pas oublier d'inclure dame.hpp et sherif.hpp car on a besoin de connaître les méthodes de ces classes pour y faire appel + pour la méthode kidnapper, + la dame prise en paramètre n'est pas const car en fin de compte elle va être modifiée par l'appel à seFaireKidnapper (elle deviendra captive). + et puisque seFaireKidnapper a une ref sur Brigand en paramètre on doit lui passer lors de l'appel le brigand qui est pointé par this et non ce que contient this(l'adresse du brigand) + dans seFaireEmprisonnerPar : ne pas oublier le booléen à retourner qui indique si le brigand a vraiment été fait prisonnier par cette action (peut être qu'il n'a pas été emprisonner ici car il l'était déjà). Et donc ne pas oublier toutes les lignes de codes de cette fonction permettant de gérer cela + dans la classe Cowboy : + dans cowboy.cpp ne pas oublier d'inclure dame.hpp et brigand.hpp car on a besoin de connaître les méthodes de ces classes pour y faire appel + pour la méthode liberer : + normalement un cowboy gagne en popularité à chaque fois qu'il libère une dame (seulement si il l'a bien libérée bien sûr) + et auparavant il la flatte + et seFaireLiberer attend un cowboy en param et pas son adresse alors on lui donne *this et pas this + et comme lors de tout cela la dame va être modifiée : elle va devenir libre par l'appel à seFaireLiberer, donc elle ne doit pas être const dans la déclaration du prototype. + quand le Cowboy tire sur un brigand, il ne fait que parler, personne n'est libéré ou modifié => méthode const et pas d'appel à liberer + dans la classe Barmen : + pas besoin de dire que les classes dame, cowboy, brigand..... existent + la methode servirVerre sert un vert à un humain de manière général. Pour savoir quel verre servir, c'est facile l'appel à la méthode getBoisson le dira. + dans le constructeur de Barmen, si pas de nom de bar fourni, il est dit dans le sujet que le nom du bar est "chez"+nom, et pas autre chose. + quand un barmen parle, il le fait comme un humain avec juste mon gars à la fin du texte + dans la classe Shérif : + dans sherif.cpp ne pas oublier d'inclure brigand.hpp car on a besoin de connaître les méthodes de cette classe pour y faire appel + méthode coffrerBrigand : + le brigand ne peut être const, il sera probablement modifié par l'appel à seFaireEmprisonner + et voir le code, je l'ai modifié + rechercherBrigand, ne fait rien d'autre que de l'affichage, ni le brigand, ni le shérif ne sont modifiés => const et const. et j'ai modifié le code. + dans le main j'ai remplacé tous les appels au narrateur par des cout . + + + diff --git a/Algo/tp/Cpp/5_tp_Antoine/Makefile b/Algo/tp/Cpp/5_tp_Antoine/Makefile new file mode 100644 index 0000000..88f4002 --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/Makefile @@ -0,0 +1,26 @@ +#CC : le compilateur à utiliser +CC=g++ + +#CFLAGS : les options de compilation +CFLAGS= -std=c++17 -Wall + +# les fichiers sources : tous les fichiers présents dans src/ +SRC=$(wildcard src/*.cpp) + +# les fichiers objets (.o) +OBJ=$(patsubst src/%.cpp,obj/%.o,$(SRC)) + + +#edition des liens : génération de l'exécutable à partir des .o +bin/exe: $(OBJ) + $(CC) $(OBJ) -o $@ + +# génération des .o à partir des .cpp et .hpp crrespondants : +obj/%.o: src/%.cpp + $(CC) $(CFLAGS) -c $< -o $@ + +#nettoyage : destruction des .o et de l'exécutable +clean: + rm obj/*.o bin/exe + + diff --git a/Algo/tp/Cpp/5_tp_Antoine/TPFarwest.pdf b/Algo/tp/Cpp/5_tp_Antoine/TPFarwest.pdf new file mode 100644 index 0000000..9e27534 Binary files /dev/null and b/Algo/tp/Cpp/5_tp_Antoine/TPFarwest.pdf differ diff --git a/Algo/tp/Cpp/5_tp_Antoine/TPFarwestSuite.pdf b/Algo/tp/Cpp/5_tp_Antoine/TPFarwestSuite.pdf new file mode 100644 index 0000000..4b2accf Binary files /dev/null and b/Algo/tp/Cpp/5_tp_Antoine/TPFarwestSuite.pdf differ diff --git a/Algo/tp/Cpp/5_tp_Antoine/bin/exe b/Algo/tp/Cpp/5_tp_Antoine/bin/exe new file mode 100755 index 0000000..7a04508 Binary files /dev/null and b/Algo/tp/Cpp/5_tp_Antoine/bin/exe differ diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/barmen.cpp b/Algo/tp/Cpp/5_tp_Antoine/src/barmen.cpp new file mode 100644 index 0000000..dcf70f9 --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/barmen.cpp @@ -0,0 +1,57 @@ +#include "barmen.hpp" + +using namespace std; + +namespace personnage { + + Barmen::Barmen(const string &nom, const string &nomBar) + : Humain(nom, "bière"), nomBar{nomBar} + {} + + Barmen::Barmen(const string &nom) + // : Humain(nom, "bière"), nomBar{"Coffee Place"} + : Humain(nom, "bière"), nomBar{"Chez "+nom} ///// comme ça d'après le sujet + {} + + string Barmen::getNomBar() const { + return this->nomBar; + } + + void Barmen::parler(const string &texte) const { + ///cout << "(" << this->getNom() << ") --- " << texte << " mon gars." << endl; + // + Humain::parler(texte + " mon gars."); // comme ça + + } + + void Barmen::sePresenter() const { + Humain::sePresenter(); + this->parler("De plus, je possede un bar qui se nomme le " + this->getNomBar()); + } + + /* + void Barmen::servirVerre(const Cowboy &cowboy) const { + this->parler("Et voilà pour toi " + cowboy.getNom() +"ton verre favori") + } + + void Barmen::servirVerre(const Dame &dame) const { + this->parler("Et voilà pour toi " + dame.getNom() +"ton verre favori") + } + + void Barmen::servirVerre(const Sherif &sherif) const { + this->parler("Et voilà pour toi " + sherif.getNom() +"ton verre favori") + } + + void Barmen::servirVerre(const Brigand &brigand) const { + this->parler("Et voilà pour toi " + brigand.getNom() +"ton verre favori") + } + */ + + + //////// voici comment il fallait faire : + void Barmen::servirVerre(const Humain & humain) const { + this->parler("Et voilà pour toi " + humain.getNom() +"un verre de " + + humain.getBoisson()); + } + +} diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/barmen.hpp b/Algo/tp/Cpp/5_tp_Antoine/src/barmen.hpp new file mode 100644 index 0000000..09e75af --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/barmen.hpp @@ -0,0 +1,40 @@ +#ifndef BARMEN_HPP +#define BARMEN_HPP + +#include +#include "humain.hpp" + + +namespace personnage { + + // class Dame; + // class Sherif; + // class Brigand; + // class Cowboy; + + class Barmen : public Humain { + + std::string nom; + std::string nomBar; + + public : + + Barmen(const std::string &nom); + Barmen(const std::string &nom, const std::string &nomBar); + + std::string getNomBar() const; + + void sePresenter() const override; + void parler(const std::string &texte) const override; + /* + void servirVerre(const Cowboy &cowboy) const; + void servirVerre(const Dame &dame) const; + void servirVerre(const Sherif &sherif) const; + void servirVerre(const Brigand &brigand) const; + */ + void servirVerre(const Humain & humain) const; /// comme ça + }; + +} + +#endif // BARMEN_HPP diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/brigand.cpp b/Algo/tp/Cpp/5_tp_Antoine/src/brigand.cpp new file mode 100644 index 0000000..d2fa409 --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/brigand.cpp @@ -0,0 +1,80 @@ +#include "brigand.hpp" +#include "dame.hpp" ///// pour connaître les méthodes de cette classe +#include "sherif.hpp" ///// necessaire pour connaître les méthodes de shérif + +#include + + +using namespace std; + +namespace personnage { + + Brigand::Brigand(const string &nom, const string &boisson, const string &comportement, const float &recompense) + : Humain(nom, boisson), comportement{comportement}, recompense{recompense} + {} + + Brigand::Brigand(const string &nom) + : Humain(nom, "tord-boyaux"), comportement{"méchant"}, recompense{100} + {} + + string Brigand::getNom() const { + return Humain::getNom() + " le " + this->comportement; + } + + float Brigand::getMiseAPrix() const { + return recompense; + } + + /////// void Brigand::kidnapper(const Dame &dame) { + void Brigand::kidnapper(Dame &dame) { // comme ça + this->parler("Ah ah !" + dame.getNom() + ", tu est mienne désormais !"); + /////// dame.seFaireKidnapper(this); + dame.seFaireKidnapper(*this); // comme ça + nbDamesEnlevees += 1; + } + + bool Brigand::seFaireEmprisonnerPar(const Sherif &sherif) { + if(enPrison){ ////// ne pas oublier ce cas !! + parler ("Tu arrives trop tard, je suis déjà en prison !"); // + return false; ////// + } + else if(sherif.getNom() == this->getNom()) { + this->parler("Je ne peux pas m'enprisonner moi-même enfin !"); + return false; + } + else{ + this->parler("Damned, je suis fait ! " + sherif.getNom() + ", tu m'as eu !"); + enPrison = true; + return true; //// ne pas oublier cette ligne + } + } + + void Brigand::seFaireScalper(const Indien &indien) { + this->parler("Aïe, ma tête... Je meurs !!"); + } + + void Brigand::sePresenter() const { + Humain::sePresenter(); + if(this->nbDamesEnlevees > 0) { + if(this->enPrison == false) { + this->parler("Je suis " + this->comportement + ", j'ai capturé " + to_string(this->nbDamesEnlevees) + " femmes au total."); //? Comment arrondir au centieme ? + this->parler("La récompense pour ma capture est de " + to_string(this->recompense) + "$"); + } + else { + this->parler("Je suis " + this->comportement + ", j'ai capturé " + to_string(this->nbDamesEnlevees) + " femmes au total, avant d'arriver en prison."); + } + } + else { + if(this->enPrison == false) { + this->parler("Je suis " + this->comportement + ", mais je n'ai toujours pas capturé de femme à ce jour ! "); //? Comment arrondir au centieme ? + this->parler("La récompense pour ma capture est de " + to_string(this->recompense) + "$"); + } + else { + this->parler("Je suis " + this->comportement + ", mais je suis allé en prison sans avoir le temps de capturé une seule femme !"); + } + } + } + + + +} diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/brigand.hpp b/Algo/tp/Cpp/5_tp_Antoine/src/brigand.hpp new file mode 100644 index 0000000..ca7c75b --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/brigand.hpp @@ -0,0 +1,44 @@ +#ifndef BRIGAND_HPP +#define BRIGAND_HPP + +#include +#include "humain.hpp" +#include "scalpable.hpp" + + + +namespace personnage { + + class Dame; + + class Sherif; + + class Brigand : virtual public Humain, public Scalpable { + + protected : + + std::string comportement; + int nbDamesEnlevees = 0; + float recompense; + bool enPrison = false; + + public: + + Brigand(const std::string &nom, const std::string &boisson, const std::string &comportement, const float &recompense); + Brigand(const std::string &nom); + + std::string getNom() const override; + float getMiseAPrix() const; + + ///////// void kidnapper(const Dame &dame); + virtual void kidnapper(Dame &dame); // comme ça + virtual bool seFaireEmprisonnerPar(const Sherif &sherif); + + void seFaireScalper(const Indien &indien) override; + + void sePresenter() const override; + }; + +} + +#endif // BRIGAND_HPP diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/cowboy.cpp b/Algo/tp/Cpp/5_tp_Antoine/src/cowboy.cpp new file mode 100644 index 0000000..89c56e2 --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/cowboy.cpp @@ -0,0 +1,51 @@ +#include "cowboy.hpp" +#include "dame.hpp" // pour connaître les méthodes de cette classe +#include "brigand.hpp" // pour connaître les méthodes de cette classe + +#include + + +using namespace std; + +namespace personnage { + + Cowboy::Cowboy(const string &nom, const string &boisson, const string &attitude) + : Humain(nom, boisson), attitude{attitude} + {} + + Cowboy::Cowboy(const string &nom) + : Humain(nom, "whisky"), attitude{"vaillant"} + {} + + // void Cowboy::liberer(const Dame &dame) { + void Cowboy::liberer(Dame &dame) { // comme ça + ///// dame.seFaireLiberer(this); + this->parler("Que vous avez une belle robe " + dame.getCouleurRobe() + ". Elle vous vas à ravir ! ;)"); + bool rep = dame.seFaireLiberer(*this); ////// comme ça + if(rep == true) popularite++; ////// + } + + // void Cowboy::tirerSur(const Brigand &brigand) { + void Cowboy::tirerSur(const Brigand &brigand)const { //// comme ça + //this->narrateur("Le " + this->attitude + " " + this->getNom() + " tire sur " + brigand.getNom() + ". PAN !"); + cout << "Le " << this->attitude << " " << this->getNom() << " tire sur " << brigand.getNom() << ". PAN !" << endl; + this->parler("Prend ça, rascal !"); + // this->liberer(); //? Comment savoir qui on doit liberer ? + //// R2ponse : on ne libère persone + } + + void Cowboy::seFaireScalper(const Indien &indien) { + this->parler("Aïe, ma tête... Je meurs !!"); + } + + void Cowboy::sePresenter() const { + Humain::sePresenter(); + if(this->popularite > 0) { + this->parler("Je suis un " + this->attitude + " cowboy. De plus, j'ai une popularité grimpante de " + to_string(this->popularite) + "."); //! Quand c'est des nb, ne pas oublier de les passer en to_string ! + } + else { + this->parler("Je suis un " + this->attitude + " cowboy, mais ma popularité est encore nulle. Un jour viendras, je serais le plus grand des cowboy du comté !!"); + } + } + +} diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/cowboy.hpp b/Algo/tp/Cpp/5_tp_Antoine/src/cowboy.hpp new file mode 100644 index 0000000..0158490 --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/cowboy.hpp @@ -0,0 +1,38 @@ +#ifndef COWBOY_HPP +#define COWBOY_HPP + +#include +#include "humain.hpp" +#include "scalpable.hpp" + +namespace personnage { + + class Dame; + + class Brigand; + + class Cowboy : virtual public Humain, public Scalpable { + + protected : + + int popularite = 0; + std::string attitude; + + public: + + Cowboy(const std::string &nom, const std::string &boisson, const std::string &attitude); + Cowboy(const std::string &nom); + + ////// void liberer(const Dame &dame); + void liberer(Dame &dame); ///// comme ça + ///// void tirerSur(const Brigand &brigand); + void tirerSur(const Brigand &brigand)const; + + void seFaireScalper(const Indien &indien) override; + + void sePresenter() const override; + }; + +} + +#endif // COWBOY_HPP diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/dame.cpp b/Algo/tp/Cpp/5_tp_Antoine/src/dame.cpp new file mode 100644 index 0000000..1e9e160 --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/dame.cpp @@ -0,0 +1,68 @@ +#include "dame.hpp" +#include "brigand.hpp" // pour connaitre les méthodes de cette classe +#include "cowboy.hpp" // pour connaitre les méthodes de cette classe +#include "indien.hpp" // pour avoir accer au infos de l'indien + +#include + + +using namespace std; + +namespace personnage { + + Dame::Dame(const string &nom, const string &boisson, const string &couleurRobe) + : Humain(nom, boisson), couleurRobe{couleurRobe} + {} + + Dame::Dame(const string &nom) + : Humain(nom, "lait"), couleurRobe{"blanche"} + {} + + string Dame::getNom() const { + return "Miss " + Humain::getNom(); + } + + string Dame::getCouleurRobe() const { + return couleurRobe; + } + + bool Dame::isCaptive() const { + return captive; + } + + void Dame::setCouleurRobe(const string &couleur) { + this->couleurRobe = couleur; + parler("Regardez ma nouvelle robe "+ couleurRobe); /////// ne pas oublier cette ligne pour respecter le sujet + } + + void Dame::seFaireKidnapper(const Brigand &brigand) { + if(brigand.getNom() == this->getNom()) { + this->parler("Mais enfin ! Je ne peux pas me kidnapper toute seule !!!"); + return; + } + this->parler("Au secour, je me fait kidnapper par " + brigand.getNom() + ". Aidez moi !!!"); + this->captive = true; + } + + bool Dame::seFaireLiberer(const Cowboy &cowboy) { + if(captive == false) { + cout << "Ah, Ah, Ah ! Mais pour qui vous prenez vous ?! Je suis une femme libre enfin !" << endl; + return false; + } + else { + cout << "Merci " << cowboy.getNom() << ", mon valeureux cowboy, je t'en suis reconnaissante !" << endl; + captive = false; ////// ne pas oublier cette ligne + return true; ////// ni celle-ci + } + } + + void Dame::seFaireScalper(const Indien &indien) { + this->parler("Oh non " + indien.getNom() + ", vous avez tâché ma belle robe " + this->getCouleurRobe() + " ... Je me meurs !!"); + } + + void Dame::sePresenter() const { + Humain::sePresenter(); + this->parler( "Et j'ai une robe de couleur " + this->couleurRobe + " qui est magnifique, en plus de me mettre en valeur !"); + } + +} diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/dame.hpp b/Algo/tp/Cpp/5_tp_Antoine/src/dame.hpp new file mode 100644 index 0000000..38ef09b --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/dame.hpp @@ -0,0 +1,43 @@ +#ifndef DAME_HPP +#define DAME_HPP + +#include +#include "humain.hpp" +#include "scalpable.hpp" + +namespace personnage { + + class Brigand; + + class Cowboy; + + class Dame : virtual public Humain, public Scalpable { + + protected : + + std::string couleurRobe; + bool captive = false; + + public: + + Dame(const std::string &nom, const std::string &boisson, const std::string &couleurRobe); + Dame(const std::string &nom); + + std::string getNom() const override; + std::string getCouleurRobe() const; + bool isCaptive() const; + + void setCouleurRobe(const std::string &couleur); + + void seFaireKidnapper(const Brigand &brigand); + bool seFaireLiberer(const Cowboy &cowboy); + + void seFaireScalper(const Indien &indien) override; + + void sePresenter() const override; + + }; + +} + +#endif // DAME_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/femmeBrigand.cpp b/Algo/tp/Cpp/5_tp_Antoine/src/femmeBrigand.cpp new file mode 100644 index 0000000..ff76707 --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/femmeBrigand.cpp @@ -0,0 +1,45 @@ +#include "femmeBrigand.hpp" +#include "sherif.hpp" +#include "dame.hpp" + +using namespace std; + +namespace personnage { + + FemmeBrigand::FemmeBrigand(const string &nom, const string &boisson, const string &couleurRobe, const string &comportement, const float &recompense) + : Humain(nom, boisson), Dame(nom, boisson, couleurRobe), Brigand(nom, boisson, comportement, recompense) + {} + + string FemmeBrigand::getNom() const { + return Dame::getNom(); + } + + void FemmeBrigand::sePresenter() const { + Dame::sePresenter(); + this->parler("La récompense pour ma capture est de " + to_string(this->recompense) + " car je suis " + this->comportement + " !!"); + } + + void FemmeBrigand::kidnapper(Dame &dame) { // comme ça + if(this->getNom() == dame.getNom()) { + this->parler("Mais enfin, je ne peut pas me kidnapper toute seule !!!"); + return; + } + this->parler("Hi hi ! Désolé " + dame.getNom() + "... encore UNE de moins qui me feras de l'ombre."); + /////// dame.seFaireKidnapper(this); + dame.seFaireKidnapper(*this); // comme ça + nbDamesEnlevees += 1; + } + + bool FemmeBrigand::seFaireEmprisonnerPar(const Sherif &sherif) { + if(enPrison){ ////// ne pas oublier ce cas !! + parler ("Tu arrives trop tard, je suis déjà en prison !"); // + return false; ////// + } + else{ + this->parler(sherif.getNom() + " ?!! Une lady comme moi ... je vous promet que je suis inocente !"); + enPrison = true; + return true; //// ne pas oublier cette ligne + } + } + +} \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/femmeBrigand.hpp b/Algo/tp/Cpp/5_tp_Antoine/src/femmeBrigand.hpp new file mode 100644 index 0000000..72f7f59 --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/femmeBrigand.hpp @@ -0,0 +1,26 @@ +#ifndef FEMMEBRIGAND_HPP +#define FEMMEBRIGAND_HPP + +#include "dame.hpp" +#include "brigand.hpp" + +namespace personnage { + + class Sherif; + + class FemmeBrigand : public Dame, public Brigand{ + + public : + + FemmeBrigand(const std::string &nom, const std::string &boisson = "lait", const std::string &couleurRobe = "blanche", const std::string &comportement = "discrète", const float &recompense = 50000); + + std::string getNom() const override; + + void kidnapper(Dame &dame) override; + bool seFaireEmprisonnerPar(const Sherif &sherif) override; + void sePresenter() const override; + + }; +} + +#endif // FEMMEBRIGAND_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/humain.cpp b/Algo/tp/Cpp/5_tp_Antoine/src/humain.cpp new file mode 100644 index 0000000..a800181 --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/humain.cpp @@ -0,0 +1,48 @@ +#include "humain.hpp" + +#include + + +using namespace std; + +namespace personnage { + + Humain::Humain(const string &nom, const string &boisson) + : nom{nom}, boisson{boisson} + {} + + Humain::Humain(const string &nom) + : nom{nom}, boisson{"eau"} + {} + + string Humain::getNom() const { + return nom; + } + + string Humain::getBoisson() const { + return boisson; + } + + void Humain::setBoisson(const string &boisson) { + this->boisson = boisson; + } + + void Humain::parler(const string &texte) const { + cout << "(" << this->nom << ") --- " << texte << endl; + } + + void Humain::sePresenter() const { + this->parler("Bonjour, je m'appelle " + this->nom + ", ma boisson favorite est le " + this->boisson); + } + /* + void Humain::narrateur(const string &texte) const { + cout << "(narrateur) --- " << texte << endl; + } + */ + void Humain::boire() const { + // cout << "Ah ! Un bon verre de " << this->boisson << " ! GLOUPS !" << endl; + parler("Ah ! Un bon verre de " + boisson + " ! GLOUPS !" ); // comme ça + } + +} + diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/humain.hpp b/Algo/tp/Cpp/5_tp_Antoine/src/humain.hpp new file mode 100644 index 0000000..6958570 --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/humain.hpp @@ -0,0 +1,31 @@ +#ifndef HUMAIN_HPP +#define HUMAIN_HPP + +#include + +namespace personnage { + + class Humain { + + std::string nom; + std::string boisson; + + public: + + Humain(const std::string &nom, const std::string &boisson); + Humain(const std::string &nom); + + virtual std::string getNom() const; + std::string getBoisson() const; + + void setBoisson(const std::string &boisson); + + virtual void parler(const std::string &texte) const; + virtual void sePresenter() const; + // void narrateur(const std::string &texte) const; + void boire() const; + }; + +} + +#endif // HUMAIN_HPP diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/indien.cpp b/Algo/tp/Cpp/5_tp_Antoine/src/indien.cpp new file mode 100644 index 0000000..0d8c9e4 --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/indien.cpp @@ -0,0 +1,24 @@ +#include "indien.hpp" + +using namespace std; + +namespace personnage { + + Indien::Indien(const string &nom, const string &boisson, const int nbPlumes, const string &totem) + :Humain(nom, boisson), nbPlumes{nbPlumes}, totem{totem} + {} + + string Indien::getNom() const { + return Humain::getNom(); + } + + void Indien::parler(const string &texte) const { + Humain::parler(texte + " Ugh !"); + } + + void Indien::sePresenter() const { + this->parler("Oyh, moi être " + this->getNom() + " et aimer " + this->getBoisson() + "."); + this->parler("Moi vénérer totem " + this->totem + ". Moi guerrier. Moi avoir " + to_string(this->nbPlumes) + " plumes."); + } + +} \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/indien.hpp b/Algo/tp/Cpp/5_tp_Antoine/src/indien.hpp new file mode 100644 index 0000000..df3a297 --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/indien.hpp @@ -0,0 +1,27 @@ +#ifndef INDIEN_HPP +#define INDIEN_HPP + +#include +#include "humain.hpp" + +namespace personnage { + + class Indien : public Humain { + + int nbPlumes; + std::string totem; + + public : + + Indien(const std::string &nom, const std::string &boisson = "jus de racines", const int nbPlumes = 0, const std::string &totem = "Coyote"); + + std::string getNom() const override; + + void parler(const std::string &texte) const override; + void sePresenter() const override; + + }; + +} + +#endif // INDIEN_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/main.cpp b/Algo/tp/Cpp/5_tp_Antoine/src/main.cpp new file mode 100644 index 0000000..f9e53f0 --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/main.cpp @@ -0,0 +1,178 @@ +#include "humain.hpp" +#include "dame.hpp" +#include "brigand.hpp" +#include "cowboy.hpp" +#include "barmen.hpp" +#include "sherif.hpp" +#include "ripou.hpp" +#include "femmeBrigand.hpp" +#include "indien.hpp" + + +using namespace std; + +void testHumain() { + personnage::Humain jacques("Jacques", "biere"); + personnage::Humain pierre("Pierre"); + pierre.setBoisson("binouse"); + jacques.sePresenter(); + pierre.sePresenter(); + jacques.boire(); + pierre.boire(); + pierre.parler("C'était bien sympa Jacques, rentrons à la maison maintenant !"); +} + +void testDame() { + personnage::Dame rose("Rose"); + personnage::Dame ginette("Ginette", "ricard", "noir"); + rose.sePresenter(); + ginette.sePresenter(); + rose.setCouleurRobe("verte"); + rose.sePresenter(); + rose.parler("J'aime les beaux cowboy !"); +} + +void testBrigand() { + personnage::Brigand robert("Robert"); + personnage::Brigand bernard("Bernard", "aveze", "ronchon", 200); + robert.sePresenter(); + bernard.sePresenter(); +} + +void testCowboy() { + personnage::Cowboy danny("Danny", "whisky", "magnifique"); + personnage::Cowboy george("George"); + danny.sePresenter(); + george.sePresenter(); +} + +void testDBHumain() { + personnage::Dame rose("Rose"); + personnage::Brigand marc("marc"); + const personnage::Humain &vilainHumain = marc; + const personnage::Humain &gentilleHumain = rose; + cout << "Je suis " << vilainHumain.getNom() << endl; + cout << "Je suis " << gentilleHumain.getNom() << endl; +} + +void testBarmen() { + personnage::Barmen jose("Jose"); + personnage::Barmen franck("Franck", "The Franchy Bar"); + jose.sePresenter(); + franck.sePresenter(); + jose.parler("J'aime les frites !!!"); +} + +void testSherif() { + personnage::Brigand robert("Robert"); + personnage::Cowboy *clint = new personnage::Sherif{"Clint"}; + clint->sePresenter(); + clint->parler("Je suis magnifique aujourd'hui. Mais comme toujours c'est vraie !"); + // clint->coffrerBrigand(robert); ///// pas possible. Lors de la compilation on aura erreur car la méthode coffrerBrigand n'existe pas pour Cowboy (type du pointeur) +} + +void testRipou() { + personnage::Ripou michel("Michel"); + personnage::Ripou morice("Morice", "Jet", "Malicieux", "Cruel", 2000); + michel.sePresenter(); + morice.sePresenter(); + michel.parler("Hello boy !!!"); + michel.tirerSur(morice); + michel.coffrerBrigand(michel); +} + +void testFemmeBrigand() { + personnage::FemmeBrigand monique{"Monique"}; + personnage::FemmeBrigand yvonne{"Yvonne", "Thé", "noir", "grogneuse", 75000}; + monique.sePresenter(); + yvonne.sePresenter(); + monique.parler("Mais que tu est belle, Yvonne !"); + monique.kidnapper(yvonne); + monique.kidnapper(monique); +} + +void testIndien() { + personnage::Indien ventDoux{"VentDoux"}; + personnage::Indien ventFort{"VentFort", "jus de pieds", 4, "Fouine"}; + ventDoux.sePresenter(); + ventFort.sePresenter(); + ventFort.parler("Oeh ventDoux !"); +} + +void testGeneral1() { + personnage::Humain pierre("Pierre"); + personnage::Dame rose("Rose"); + personnage::Dame ginette("Ginette", "ricard", "noir"); + personnage::Brigand robert("Robert"); + personnage::Brigand bernard("Bernard", "aveze", "ronchon", 200); + personnage::Cowboy george("George"); + personnage::Barmen franck("Franck", "The Franchy Bar"); + personnage::Sherif clint("Clint"); + cout << "Il était une fois, une jeune et belle dame qui se promenait dans les bois avec une amie.\n"; + rose.sePresenter(); + ginette.sePresenter(); + rose.parler("Qu'il fait beau aujourd'hui !!"); + cout << "Tout allait bien dans le meilleur des mondes, jusqu'à ce que deux brigands apparurent.\n"; + robert.sePresenter(); + bernard.sePresenter(); + robert.parler("Nous allons vous kidnapper pauvres dames !!"); + bernard.kidnapper(rose); + robert.kidnapper(ginette); + cout <<"Les pauvres Rose et Ginette se firent kidnapper par ses deux truans. Mais un vieux cowboy n'est pas loin\n"; + george.sePresenter(); + george.parler("Que faites vous bande de mal autrus !!!"); + george.tirerSur(robert); + george.tirerSur(bernard); + bernard.parler("Tu nous a loupé veillard !!"); + george.liberer(ginette); + robert.parler("À bientôt l'ancien !!"); + cout <<"Et les deux brigands pure s'en aller paisiblement car la vieux cowboy ne tiré plus tout droit.\n"; + cout <<"Surtout avec tout l'alcool qu'il s'était enpiffré. Mais il réussi quand même à liberer une des deux filles.\n"; + cout <<"Et notre cowboy retourna au bar pour se remettre de ses émotions.\n"; + george.parler("Hey Franck, un verre stp pour moi et cette dame !"); + franck.servirVerre(george); + franck.servirVerre(ginette); + franck.parler("Alors ces brigands ?!"); + george.parler("Ils se sont enfuit, j'ai plus la forme comme avant ! Mais j'ai réussi à liberer cette dame."); + cout <<"Pendant ce temps là, les brigands s'échappe toujours. Notre cowboy décide donc d'en informer le Shérif.\n"; + george.parler("Sherif !! J'ai deux brigands qui m'on échapés."); + clint.parler("Très bien george. Repose toi ! Je prends le relais"); + clint.rechercherBrigand(bernard); + clint.rechercherBrigand(robert); + cout <<"Cela s'annonce compliqué pour notre Shérif !!\n"; + clint.parler("Où on-t-il bien pu partir ???"); + pierre.sePresenter(); + pierre.parler("Sherif ! J'ai vu ces deux gangster avec une très jolie femme avec eux !"); + clint.parler("Et où ça ?"); + pierre.parler("Ils sont près de la gare !!!"); + clint.parler("En avant mon fidèle destrier pilepoil !!"); + cout <<"Notre Shérif entama donc son périple vers la gare avec son cheval pile-poil.\n"; + cout <<"Une fois arrivé, il se cacha et s'approcha discrètement de ses deux brigands avant de les intercepter.\n"; + clint.coffrerBrigand(robert); + clint.tirerSur(bernard); + clint.coffrerBrigand(bernard); + clint.liberer(rose); + rose.parler("Mais que vous êtes merveuilleux mon shérif !!"); + clint.parler("Pour vous servir Miss rose."); + cout <<"Nos deux personnage partir tout deux heureux.\n"; +} + +void testGeneral2() { + // vector +} + + +int main() { + // testHumain(); + // testDame(); + // testBrigand(); + // testCowboy(); + // testDBHumain(); + // testBarmen(); + // testSherif(); + // testRipou(); + // testFemmeBrigand(); + // testIndien(); + // testGeneral1(); + return 0; +} diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/ripou.cpp b/Algo/tp/Cpp/5_tp_Antoine/src/ripou.cpp new file mode 100644 index 0000000..d37e20c --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/ripou.cpp @@ -0,0 +1,21 @@ +#include "ripou.hpp" + +using namespace std; + +namespace personnage { + + Ripou::Ripou(const string &nom, const string &boisson, const string &attitude, const string &comportement, const float &recompense) + : Humain(nom, boisson), Sherif(nom, boisson, attitude), Brigand(nom, boisson, comportement, recompense) + {} + + string Ripou::getNom() const { + return Sherif::getNom() + "(aka " + Brigand::getNom() + ")"; + } + + void Ripou::sePresenter() const { + Sherif::sePresenter(); + this->parler("Personne ne doit le savoir, mais j'ai kidnappé " + to_string(this->nbDamesEnlevees) + " dames, je suis un vrai " + this->comportement + " !"); + this->parler("Celui qui me démasque pourra gagner " + to_string(this->getMiseAPrix()) + "$."); + } + +} \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/ripou.hpp b/Algo/tp/Cpp/5_tp_Antoine/src/ripou.hpp new file mode 100644 index 0000000..3a2a260 --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/ripou.hpp @@ -0,0 +1,29 @@ +#ifndef RIPOU_HPP +#define RIPOU_HPP + +#include + +#include "sherif.hpp" +#include "brigand.hpp" + +namespace personnage { + + class Ripou : public Sherif, public Brigand { + + std::string nom; + + public : + + Ripou(const std::string &nom, const std::string &boisson = "gin", const std::string &attitude = "silencieux", const std::string &comportement = "sournois", const float &recompense = 1000); + + std::string getNom() const override; + + void sePresenter() const override; + + }; + +} + + + +#endif // RIPOU_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/scalpable.cpp b/Algo/tp/Cpp/5_tp_Antoine/src/scalpable.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/scalpable.hpp b/Algo/tp/Cpp/5_tp_Antoine/src/scalpable.hpp new file mode 100644 index 0000000..2c8a8fb --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/scalpable.hpp @@ -0,0 +1,20 @@ +#ifndef SCALPABLE_HPP +#define SCALPABLE_HPP + +#include + +namespace personnage { + + class Indien; + + class Scalpable { + + public : + + virtual void seFaireScalper(const Indien &indien) = 0; + + }; + +} + +#endif // SCALPABLE_HPP \ No newline at end of file diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/sherif.cpp b/Algo/tp/Cpp/5_tp_Antoine/src/sherif.cpp new file mode 100644 index 0000000..a9abd6b --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/sherif.cpp @@ -0,0 +1,69 @@ +#include "sherif.hpp" +#include "brigand.hpp" // pour connaître les méthodes de cette classe + +using namespace std; + +namespace personnage { + + Sherif::Sherif(const string &nom) + : Humain(nom, "Tekila"), Cowboy(nom, "Tekila", "honnête") + {} + + Sherif::Sherif(const string &nom, const string &boisson, + const string &attitude) + : Humain(nom, boisson), Cowboy(nom, boisson, attitude) + {} + + string Sherif::getNom() const { + return "Shérif " + Cowboy::getNom(); + } + + /* + void Sherif::coffrerBrigand(const Brigand &brigand) { + if() { //? Comment verifier s'il est en prison ? + this->parler(brigand.getNom() + " au nom de la loi, + je vous arrête !!") + brigand.seFaireEmprisonerPar(this); + } + } + */ + + void Sherif::coffrerBrigand(Brigand &brigand) { // comme ça + if(brigand.getNom() == this->getNom()) { + this->parler("Je ne peux pas m'emprisonner moi-même enfin !!"); + return; + } + else { + this->parler(brigand.getNom() + " au nom de la loi, je vous arrête !!"); + bool rep = brigand.seFaireEmprisonnerPar(*this); // comme ça + if(rep == true) nbBrigands++; ///// comme ça + } + } + + + /* + void Sherif::rechercherBrigand(const Brigand &brigand) { + //? Comment l'écrire sans utiliser de find a chaque fois ? + Humain::narrateur("OYEZ OYEZ BRAVE GENS !! " + + brigand.getMiseAPrix() + " $ à qui arrêtera " + brigand.getNom() + + "mort ou vif !!"); + } + */ + + + /// c'est comme ça : + void Sherif::rechercherBrigand(const Brigand &brigand)const { + if(brigand.getNom() == this->getNom()) { + this->parler("Je ne peut pas me revchercher moi-même enfin !!!"); + return; + } + parler("OYEZ OYEZ BRAVE GENS !! " + to_string(brigand.getMiseAPrix()) + " $ à qui arrêtera " + brigand.getNom() + "mort ou vif !!"); + } + + void Sherif::sePresenter() const { + Cowboy::sePresenter(); + this->parler("Et j'ai à mon actif " + to_string(this->nbBrigands) + " capturé."); + } + + +} diff --git a/Algo/tp/Cpp/5_tp_Antoine/src/sherif.hpp b/Algo/tp/Cpp/5_tp_Antoine/src/sherif.hpp new file mode 100644 index 0000000..a811332 --- /dev/null +++ b/Algo/tp/Cpp/5_tp_Antoine/src/sherif.hpp @@ -0,0 +1,34 @@ +#ifndef SHERIF_HPP +#define SHERIF_HPP + +#include +#include "cowboy.hpp" + +namespace personnage { + + class Brigand; + + class Sherif : public Cowboy { + + std::string nom; + int nbBrigands = 0; + + public : + + Sherif(const std::string &nom); + Sherif(const std::string &nom, const std::string &boisson, const std::string &attitude); + + std::string getNom() const override; + + /// void coffrerBrigand(const Brigand &brigand); + void coffrerBrigand(Brigand &brigand); ///// comme ça + /// void rechercherBrigand(const Brigand &brigand); + void rechercherBrigand(const Brigand &brigand)const; // comme ça + void sePresenter() const override; + + }; + +} + + +#endif // SHERIF_HPP diff --git a/PPP/s2/CV_PPP.jpg b/PPP/s2/CV_PPP.jpg new file mode 100644 index 0000000..8475b21 Binary files /dev/null and b/PPP/s2/CV_PPP.jpg differ diff --git a/PPP/s2/CV_PPP2.jpg b/PPP/s2/CV_PPP2.jpg new file mode 100644 index 0000000..6e21864 Binary files /dev/null and b/PPP/s2/CV_PPP2.jpg differ diff --git a/PPP/s2/Le métier de développeur.docx b/PPP/s2/Le métier de développeur.docx index 27eff3d..eaac1fa 100644 Binary files a/PPP/s2/Le métier de développeur.docx and b/PPP/s2/Le métier de développeur.docx differ diff --git a/SAE/SAE2.02-Exploitation_algorithmique_d_un_probleme b/SAE/SAE2.02-Exploitation_algorithmique_d_un_probleme new file mode 160000 index 0000000..ebe5187 --- /dev/null +++ b/SAE/SAE2.02-Exploitation_algorithmique_d_un_probleme @@ -0,0 +1 @@ +Subproject commit ebe5187bbfe48165a8fab6efcec0f69ba17187ee diff --git a/SAE/~$E2.06-Travail_d_equipe.docx b/SAE/~$E2.06-Travail_d_equipe.docx deleted file mode 100644 index 2b3d870..0000000 Binary files a/SAE/~$E2.06-Travail_d_equipe.docx and /dev/null differ diff --git a/SIFinancier/SIFi2.jpg b/SIFinancier/SIFi2.jpg new file mode 100644 index 0000000..32fa8c0 Binary files /dev/null and b/SIFinancier/SIFi2.jpg differ diff --git a/SIFinancier/SIFi3.jpg b/SIFinancier/SIFi3.jpg new file mode 100644 index 0000000..f8eca40 Binary files /dev/null and b/SIFinancier/SIFi3.jpg differ diff --git a/SIFinancier/SIFinancier.jpg b/SIFinancier/SIFinancier.jpg new file mode 100644 index 0000000..69b80a3 Binary files /dev/null and b/SIFinancier/SIFinancier.jpg differ