diff --git a/src/Personne2.cpp b/src/Personne2.cpp index 93299e0..84651d9 100644 --- a/src/Personne2.cpp +++ b/src/Personne2.cpp @@ -40,6 +40,7 @@ void Personne::affichListe() { + ostream& reseau2::operator<<(ostream& os, Personne p) { return os << p.getPrenom(); } diff --git a/src/Personne2.h b/src/Personne2.h index e99bde9..7653822 100644 --- a/src/Personne2.h +++ b/src/Personne2.h @@ -7,7 +7,7 @@ namespace reseau2 { class Personne { std::string prenom; - std::list allPerson; + std::list allPerson; // std::map> map; public: diff --git a/src/main.cpp b/src/main.cpp index 27f08ab..5fb29cd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,12 +1,12 @@ #include -#include -#include /* on récupère thread afin de faire un sleep pour l'esthétique du menu */ +#include #include "Personne.hpp" -#include"Contact.hpp" +#include "Contact.hpp" +#include "Personne2.h" using namespace std; using namespace reseau; -using this_thread::sleep_for; +using this_thread::sleep_for; void technique1(){ @@ -124,11 +124,7 @@ void technique3(){ Contacts.push_back(&c14); reseau::Contact c15{p15}; Contacts.push_back(&c15); - - - /* - On place les contacts directs dans une liste de personne qui correspond au répertoire de chaque personne - */ + // cout << "----------\n"; c1.ajouterContact(p2); c1.ajouterContact(p5); c1.ajouterContact(p4); @@ -152,160 +148,165 @@ void technique3(){ c14.ajouterContact(p13); c15.ajouterContact(p9); - vector Repertoire = { c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15 }; - - int i=1; - Repertoire[i].afficherContactDirect(); - /* - Début du menu et initialisation des variables qu'on utilisera pour chaque partie de celui-ci - */ int choix, choix2, choix3, persChoix; cout <<"\n ---------------------------------------------------------------\n | Technique n°3 (1) | Technique n°2 (2) | Sortir (3) |\n ---------------------------------------------------------------\n\n--> "; cin >> choix; switch(choix) { - /* - Le cas 1 et le cas 2 feront le même code au début donc on appliquera leurs différences plus tard dans un if - */ + case 1 : case 2 : cout << "\n -------------------------------------------------------------\n | Cas global (1) | Cas individuel (2) | Retour (3) |\n -------------------------------------------------------------\n\n--> "; cin >> choix2; switch(choix2) { - /* - Le cas 1 et le cas 2 feront le même code au début donc on appliquera leurs différences plus tard dans un if - */ + case 1: case 2: cout <<"\n -------------------------------------------------------------------\n | Contact Direct (1) | Contact Indirect (2) | Retour (3) |\n -------------------------------------------------------------------\n\n--> "; cin >> choix3; switch(choix3) { - /* - Le cas 1 et le cas 2 feront le même code au début donc on appliquera leurs différences plus tard dans un autre switch - */ case 1: case 2: - - /* - On applique en fonction de notre choix2 les méthodes et l'affichage voulu, afin d'éviter des répétitions dans les case. - */ if(choix2==2){ cout << "\n Choisissez la personne que vous voulez regarder : \n\n--------------------\n(1)\tBob\n(2)\tDomi\n(3)\tAnne\n(4)\tElie\n(5)\tCali\n(6)\tSamuel\n(7)\tElena\n(8)\tBaptiste\n(9)\tFranck\n(10)\tAgathe\n(11)\tLouna\n(12)\tTheo\n(13)\tMorgane\n(14)\tThibault\n(15)\tGwen\n--------------------\n\n Tapez le numéro de la personne : "; cin >> persChoix ; cout << "\n"; - - /* - On sépare les méthodes que l'on veut utiliser en fonction de la Technique choisi au début dans la variable choix avec un if et un else - */ - if(choix==1){ - /* - On applique en fonction de notre choix3 les méthodes voulu, afin d'éviter des répétitions dans les case. - */ - switch(choix3) { - case 1: - /* - En fonction de la personne choisi avec la variable persChoix, il affiche ses contacts directs - */ - Repertoire[persChoix-1].afficherContactDirect(); - break; - case 2: - /* - En fonction de la personne choisi avec la variable persChoix, il affiche sa propagation - */ - Repertoire[persChoix-1].afficherContactIndirect(Contacts); - break; - } - } - else{ - switch(choix3) { /* TEHCNIQUE N°2*/ - case 1: - /* - En fonction de la personne choisi avec la variable persChoix, il affiche ses contacts directs - */ - Repertoire[persChoix-1].afficherContactDirect(); - break; - case 2: - /* - En fonction de la personne choisi avec la variable persChoix, il affiche sa propagation - */ - Repertoire[persChoix-1].afficherContactIndirect(Contacts); - break; - } + switch(choix3) { + case 1: + if(persChoix==1) + c1.afficherContactDirect(); + if(persChoix==2) + c2.afficherContactDirect(); + if(persChoix==3) + c3.afficherContactDirect(); + if(persChoix==4) + c4.afficherContactDirect(); + if(persChoix==5) + c5.afficherContactDirect(); + if(persChoix==6) + c6.afficherContactDirect(); + if(persChoix==7) + c7.afficherContactDirect(); + if(persChoix==8) + c8.afficherContactDirect(); + if(persChoix==9) + c9.afficherContactDirect(); + if(persChoix==10) + c10.afficherContactDirect(); + if(persChoix==11) + c11.afficherContactDirect(); + if(persChoix==12) + c12.afficherContactDirect(); + if(persChoix==13) + c13.afficherContactDirect(); + if(persChoix==14) + c14.afficherContactDirect(); + if(persChoix==15) + c15.afficherContactDirect(); + break; + case 2: + if(persChoix==1) + c1.afficherContactIndirect(Contacts); + if(persChoix==2) + c2.afficherContactIndirect(Contacts); + if(persChoix==3) + c3.afficherContactIndirect(Contacts); + if(persChoix==4) + c4.afficherContactIndirect(Contacts); + if(persChoix==5) + c5.afficherContactIndirect(Contacts); + if(persChoix==6) + c6.afficherContactIndirect(Contacts); + if(persChoix==7) + c7.afficherContactIndirect(Contacts); + if(persChoix==8) + c8.afficherContactIndirect(Contacts); + if(persChoix==9) + c9.afficherContactIndirect(Contacts); + if(persChoix==10) + c10.afficherContactIndirect(Contacts); + if(persChoix==11) + c11.afficherContactIndirect(Contacts); + if(persChoix==12) + c12.afficherContactIndirect(Contacts); + if(persChoix==13) + c13.afficherContactIndirect(Contacts); + if(persChoix==14) + c14.afficherContactIndirect(Contacts); + if(persChoix==15) + c15.afficherContactIndirect(Contacts); + break; } } else{ - if(choix==1){ - switch(choix3){ - case 1: - /* - On affiche les contacts directs de tout le réseau - */ - for (long unsigned int i=0; i