#include #include /* on récupère thread afin de faire un sleep pour l'esthétique du menu */ #include "Personne.hpp" #include"Contact.hpp" using namespace std; using namespace reseau; using this_thread::sleep_for; int main(){ /* On crée chaque personne qui seront dans notre réseau */ Personne p1{"Bob"}; Personne p2{"Domi"}; Personne p3{"Anne"}; Personne p4{"Elie"}; Personne p5{"Cali"}; Personne p6{"Samuel"}; Personne p7{"Elena"}; Personne p8{"Baptiste"}; Personne p9{"Franck"}; Personne p10{"Agathe"}; Personne p11{"Louna"}; Personne p12{"Theo"}; Personne p13{"Morgane"}; Personne p14{"Thibault"}; Personne p15{"Gwen"}; list Contacts; // cout << "----------\n"; /* On crée les contacts en mettant leur propiétaire, on ajoute ensuite chaque contact dans une liste juste après leur construction */ Contact c1{p1}; Contacts.push_back(&c1); Contact c2{p2}; Contacts.push_back(&c2); Contact c3{p3}; Contacts.push_back(&c3); Contact c4{p4}; Contacts.push_back(&c4); Contact c5{p5}; Contacts.push_back(&c5); Contact c6{p6}; Contacts.push_back(&c6); Contact c7{p7}; Contacts.push_back(&c7); Contact c8{p8}; Contacts.push_back(&c8); Contact c9{p9}; Contacts.push_back(&c9); Contact c10{p10}; Contacts.push_back(&c10); Contact c11{p11}; Contacts.push_back(&c11); Contact c12{p12}; Contacts.push_back(&c12); Contact c13{p13}; Contacts.push_back(&c13); Contact c14{p14}; Contacts.push_back(&c14); Contact c15{p15}; Contacts.push_back(&c15); // cout << "----------\n"; /* On place les contacts directs dans une liste de personne qui correspond au répertoire de chaque personne */ c1.ajouterContact(p2); c1.ajouterContact(p5); c1.ajouterContact(p4); c3.ajouterContact(p1); c3.ajouterContact(p2); c4.ajouterContact(p5); c4.ajouterContact(p6); c5.ajouterContact(p4); c6.ajouterContact(p7); c6.ajouterContact(p9); c7.ajouterContact(p3); c8.ajouterContact(p2); c9.ajouterContact(p6); c9.ajouterContact(p11); c10.ajouterContact(p7); c10.ajouterContact(p8); c11.ajouterContact(p15); c12.ajouterContact(p10); c13.ajouterContact(p11); c14.ajouterContact(p12); c14.ajouterContact(p13); c15.ajouterContact(p9); // cout << "----------\n"; // c1.rechercher(p3); // c1.rechercher(p2); // c1.rechercher(p5); // cout << "----------\n"; /* 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 applique en fonction de notre choix3 les méthodes voulu, afin d'éviter des répétitions dans les case. */ if(choix==1){ switch(choix3) { case 1: /* En fonction de la personne choisi avec la variable persChoix, il affiche ses contacts directs */ 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: /* En fonction de la personne choisi avec la variable persChoix, il affiche sa propagation */ 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{ switch(choix3) { /* TEHCNIQUE N°2*/ case 1: /* En fonction de la personne choisi avec la variable persChoix, il affiche ses contacts directs */ 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: /* En fonction de la personne choisi avec la variable persChoix, il affiche sa propagation */ 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 */ c1.afficherContactDirect(); c2.afficherContactDirect(); c3.afficherContactDirect(); c4.afficherContactDirect(); c5.afficherContactDirect(); c6.afficherContactDirect(); c7.afficherContactDirect(); c8.afficherContactDirect(); c9.afficherContactDirect(); c10.afficherContactDirect(); c11.afficherContactDirect(); c12.afficherContactDirect(); c13.afficherContactDirect(); c14.afficherContactDirect(); c15.afficherContactDirect(); break; case 2: /* On affiche la propagation de tout le réseau */ c1.afficherContactIndirect(Contacts); c2.afficherContactIndirect(Contacts); c3.afficherContactIndirect(Contacts); c4.afficherContactIndirect(Contacts); c5.afficherContactIndirect(Contacts); c6.afficherContactIndirect(Contacts); c7.afficherContactIndirect(Contacts); c8.afficherContactIndirect(Contacts); c9.afficherContactIndirect(Contacts); c10.afficherContactIndirect(Contacts); c11.afficherContactIndirect(Contacts); c12.afficherContactIndirect(Contacts); c13.afficherContactIndirect(Contacts); c14.afficherContactIndirect(Contacts); c15.afficherContactIndirect(Contacts); break; } } else{ switch(choix3){ /* TEHCNIQUE N°2*/ case 1: /* On affiche les contacts directs de tout le réseau */ c1.afficherContactDirect(); c2.afficherContactDirect(); c3.afficherContactDirect(); c4.afficherContactDirect(); c5.afficherContactDirect(); c6.afficherContactDirect(); c7.afficherContactDirect(); c8.afficherContactDirect(); c9.afficherContactDirect(); c10.afficherContactDirect(); c11.afficherContactDirect(); c12.afficherContactDirect(); c13.afficherContactDirect(); c14.afficherContactDirect(); c15.afficherContactDirect(); break; case 2: /* On affiche la propagation de tout le réseau */ c1.afficherContactIndirect(Contacts); c2.afficherContactIndirect(Contacts); c3.afficherContactIndirect(Contacts); c4.afficherContactIndirect(Contacts); c5.afficherContactIndirect(Contacts); c6.afficherContactIndirect(Contacts); c7.afficherContactIndirect(Contacts); c8.afficherContactIndirect(Contacts); c9.afficherContactIndirect(Contacts); c10.afficherContactIndirect(Contacts); c11.afficherContactIndirect(Contacts); c12.afficherContactIndirect(Contacts); c13.afficherContactIndirect(Contacts); c14.afficherContactIndirect(Contacts); c15.afficherContactIndirect(Contacts); break; } } } break; case 3: /* les deux prochains case sont là pour appeler récursivement le main et donc notre menu */ main(); break; } break; case 3: main(); break; } /* On attend 8 secondes après l'affichage de nos commandes puis on effache tout, pour avoir un ternimal vide entre chaque utilisation */ sleep_for(8s); system("clear"); main(); break; case 3 : /* le return sert pour arrêter le programme lorsqu'on demande l'exit sur le premier menu*/ return 0; break; } }