diff --git a/TP8/COQ/COQ.sln b/TP8/COQ/COQ.sln
new file mode 100644
index 0000000..4c24de5
--- /dev/null
+++ b/TP8/COQ/COQ.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.7.34221.43
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "COQ", "COQ.vcxproj", "{B01EA899-3FB4-4537-BC98-F70A30C56399}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {B01EA899-3FB4-4537-BC98-F70A30C56399}.Debug|x64.ActiveCfg = Debug|x64
+ {B01EA899-3FB4-4537-BC98-F70A30C56399}.Debug|x64.Build.0 = Debug|x64
+ {B01EA899-3FB4-4537-BC98-F70A30C56399}.Debug|x86.ActiveCfg = Debug|Win32
+ {B01EA899-3FB4-4537-BC98-F70A30C56399}.Debug|x86.Build.0 = Debug|Win32
+ {B01EA899-3FB4-4537-BC98-F70A30C56399}.Release|x64.ActiveCfg = Release|x64
+ {B01EA899-3FB4-4537-BC98-F70A30C56399}.Release|x64.Build.0 = Release|x64
+ {B01EA899-3FB4-4537-BC98-F70A30C56399}.Release|x86.ActiveCfg = Release|Win32
+ {B01EA899-3FB4-4537-BC98-F70A30C56399}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {CEFA4EB7-CAEA-4B51-B46C-5AAD3C89E542}
+ EndGlobalSection
+EndGlobal
diff --git a/TP8/COQ/COQ.vcxproj b/TP8/COQ/COQ.vcxproj
new file mode 100644
index 0000000..4a5117a
--- /dev/null
+++ b/TP8/COQ/COQ.vcxproj
@@ -0,0 +1,135 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 17.0
+ Win32Proj
+ {b01ea899-3fb4-4537-bc98-f70a30c56399}
+ COQ
+ 10.0
+
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Level3
+ true
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TP8/COQ/COQ.vcxproj.filters b/TP8/COQ/COQ.vcxproj.filters
new file mode 100644
index 0000000..5d997ac
--- /dev/null
+++ b/TP8/COQ/COQ.vcxproj.filters
@@ -0,0 +1,22 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Fichiers sources
+
+
+
\ No newline at end of file
diff --git a/TP8/COQ/COQ.vcxproj.user b/TP8/COQ/COQ.vcxproj.user
new file mode 100644
index 0000000..88a5509
--- /dev/null
+++ b/TP8/COQ/COQ.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/TP8/COQ/Côté_Coq_Poule.pdf b/TP8/COQ/Côté_Coq_Poule.pdf
new file mode 100644
index 0000000..87edbcb
Binary files /dev/null and b/TP8/COQ/Côté_Coq_Poule.pdf differ
diff --git a/TP8/COQ/main.cpp b/TP8/COQ/main.cpp
new file mode 100644
index 0000000..4a11276
--- /dev/null
+++ b/TP8/COQ/main.cpp
@@ -0,0 +1,245 @@
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+class Poule;
+class Oeuf;
+
+template
+void affiche_cont(C& cont) {
+ for (auto& volaille : cont) {
+ volaille.affiche();
+ cout << endl;
+ }
+}
+
+class Coq {
+ string Nom;
+ int Age;
+
+public:
+ void saisie();
+ void affiche();
+
+ Oeuf Cocorico(Poule p);
+
+ bool operator<(Coq& c2) {
+ return Age < c2.Age;
+ }
+
+ template
+ void CocoricoPoules(C&c) {
+ vector oeufs;
+ oeufs.reserve(c.size());
+ for (auto poule : c) {
+ oeufs.push_back(Cocorico(poule));
+ }
+ affiche_cont(oeufs);
+ }
+};
+
+class Poule {
+ string Nom;
+ int Poids;
+
+ friend Coq;
+
+protected:
+ void set_poids(int poids) { Poids = poids; }
+
+public:
+ void saisie();
+ void affiche();
+
+ float get_poids() {
+ return Poids;
+ }
+
+ bool operator<(Poule& c2) {
+ return Poids < c2.Poids;
+ }
+};
+
+class Oeuf : public Poule {
+ char Qualite;
+
+public:
+ Oeuf(int poids) {
+ set_poids(poids);
+
+ cout << "L'oeuf a bien ete pondu et pese : "<
+void saisie(C& cont, const string nom) {
+ int n;
+
+ cout << "Combien de " << nom << " ? : ";
+ cin >> n; cin.ignore();
+
+ while (n-- > 0) {
+ T p;
+ p.saisie();
+ cont.insert(cont.begin(), p);
+ }
+}
+
+
+
+int poids_poules(list poules) {
+ int S = 0;
+ for (Poule& p : poules) {
+ S += p.get_poids() / 1000;
+ }
+ return S;
+}
+
+pair couple(list poules, vector coqs) {
+ auto poule = max_element(poules.begin(), poules.end());
+ auto coq = min_element(coqs.begin(), coqs.end());
+
+ if (poule == poules.end() || coq == coqs.end()) {
+ cout << "Aucun couple n'a pu être formé";
+ exit(1);
+ }
+
+ cout << "Le couple formé est ";
+ coq->affiche();
+ cout << " et ";
+ poule->affiche();
+ cout << endl;
+
+ return make_pair(*poule, *coq);
+}
+
+Coq plus_vieux_coq(vector coqs) {
+ auto coq = max_element(coqs.begin(), coqs.end());
+ if (coq == coqs.end()) {
+ cout << "Il n'y a pas de coq!";
+ exit(1);
+ }
+ return *coq;
+}
+
+// Faut-il effacer l'unique élément si le conteneur ne contient qu'un seul élément ?
+// Supprimer la première moitié? que vaut la moitié pour 1 élement.
+template
+void effacer_moitie(C& c) {
+ auto it = c.begin();
+ for (int i = 0; i < c.size() / 2; i++) it++;
+
+ c.erase(c.begin(), it);
+}
+
+int menu() {
+ int c;
+
+ cout << "1) Saisir_Clav 1 List de Poule(s) (insertion au début) + Affichage" << endl
+ << "2) Saisir_Clav 1 Vector de Coq(s) (insertion au début) + Affichage" << endl
+ << "3) Calculer et afficher la Somme des poids en Kg : Sp" << endl
+ << "4) Le plus jeune des Coqs épouse la Poule la plus lourde" << endl
+ << "5) Le Coq fait Cocorico et toutes les Poules pondent + Affichage" << endl
+ << "6) Effacer la première moitié de List et de Vector + Affichage" << endl
+ << "Votre choix : ";
+
+ cin >> c; cin.ignore();
+ return c;
+}
+
+int main() {
+ list poules;
+ vector coqs;
+
+ float Sp;
+
+ setlocale(LC_ALL, "");
+
+ while (true) {
+ switch (menu()) {
+ case 1:
+ saisie, Poule>(poules, "Poules");
+ affiche_cont(poules);
+ break;
+
+ case 2:
+ saisie, Coq>(coqs, "Coqs");
+ affiche_cont(coqs);
+ break;
+
+ case 3:
+ Sp = poids_poules(poules);
+ cout << "Somme de Poids des poules en Kg : " << Sp;
+
+ break;
+ case 4:
+ couple(poules, coqs);
+
+ break;
+
+ // Cocorico
+ case 5:
+ plus_vieux_coq(coqs).CocoricoPoules(poules);
+ break;
+ case 6:
+ effacer_moitie(coqs);
+ effacer_moitie(poules);
+
+ affiche_cont(coqs);
+ affiche_cont(poules);
+
+ break;
+
+ default:
+ return 0;
+ }
+ }
+
+ return 0;
+}
+
+void Poule::saisie() {
+ cout << "Le nom ? : ";
+ getline(cin, Nom);
+ cout << "Le poids ? : ";
+ cin >> Poids; cin.ignore();
+}
+
+void Coq::saisie() {
+ cout << "Le nom ? : ";
+ getline(cin, Nom);
+ cout << "L' age ? : ";
+ cin >> Age; cin.ignore();
+}
+
+void Poule::affiche() {
+ cout << Nom << "(" << Poids << ") ";
+}
+
+void Coq::affiche() {
+ cout << Nom << "(" << Age << ") ";
+}
+
+void Oeuf::affiche() {
+ cout << Qualite << "(" << get_poids() << "gr)";
+}
+
+void Oeuf::saisie() {
+ cout << "Saisir qualité de l'oeuf (A, B ou C) ? : ";
+ cin >> Qualite;
+}
+
+Oeuf Coq::Cocorico(Poule p) {
+ Oeuf oeuf(p.get_poids() / 10);
+
+ oeuf.saisie();
+
+ return oeuf;
+}
\ No newline at end of file