@ -1,82 +1,20 @@
# include <iostream>
# include <iostream>
# include <thread >
# include <vector >
# include "Personne.hpp"
# include "Personne.hpp"
# include "Contact.hpp "
# include "Personne2.h "
# include "Personne2.h "
# include "Contact.hpp "
using namespace std ;
using namespace std ;
using namespace reseau ;
using namespace reseau ;
using this_thread : : sleep_for ;
void technique1 ( ) {
reseau2 : : Personne p1 { " Bob " } ;
reseau2 : : Personne p2 { " Domi " } ;
reseau2 : : Personne p3 { " Anne " } ;
reseau2 : : Personne p4 { " Elie " } ;
reseau2 : : Personne p5 { " Cali " } ;
reseau2 : : Personne p6 { " Samuel " } ;
reseau2 : : Personne p7 { " Elena " } ;
reseau2 : : Personne p8 { " Baptiste " } ;
reseau2 : : Personne p9 { " Franck " } ;
reseau2 : : Personne p10 { " Agathe " } ;
reseau2 : : Personne p11 { " Louna " } ;
reseau2 : : Personne p12 { " Theo " } ;
reseau2 : : Personne p13 { " Morgane " } ;
reseau2 : : Personne p14 { " Thibault " } ;
reseau2 : : Personne p15 { " Gwen " } ;
p1 . ajoutListe ( p2 ) ;
p1 . ajoutListe ( p5 ) ;
p1 . ajoutListe ( p4 ) ;
p3 . ajoutListe ( p1 ) ;
p3 . ajoutListe ( p2 ) ;
p4 . ajoutListe ( p5 ) ;
p4 . ajoutListe ( p6 ) ;
p5 . ajoutListe ( p4 ) ;
p6 . ajoutListe ( p7 ) ;
p6 . ajoutListe ( p9 ) ;
p7 . ajoutListe ( p3 ) ;
p8 . ajoutListe ( p2 ) ;
p9 . ajoutListe ( p6 ) ;
p9 . ajoutListe ( p11 ) ;
p10 . ajoutListe ( p7 ) ;
p10 . ajoutListe ( p8 ) ;
p11 . ajoutListe ( p15 ) ;
p12 . ajoutListe ( p10 ) ;
p13 . ajoutListe ( p11 ) ;
p14 . ajoutListe ( p12 ) ;
p14 . ajoutListe ( p13 ) ;
p15 . ajoutListe ( p9 ) ;
p1 . affichListe ( ) ;
p2 . affichListe ( ) ;
p3 . affichListe ( ) ;
p4 . affichListe ( ) ;
p5 . affichListe ( ) ;
p6 . affichListe ( ) ;
p7 . affichListe ( ) ;
p8 . affichListe ( ) ;
p9 . affichListe ( ) ;
p10 . affichListe ( ) ;
p11 . affichListe ( ) ;
p12 . affichListe ( ) ;
p13 . affichListe ( ) ;
p14 . affichListe ( ) ;
p15 . affichListe ( ) ;
for ( reseau2 : : Personne p : p1 . listePersonneAll )
{
cout < < p < < " , \n " ;
}
int main ( ) {
/*
On cr é e chaque personne qui seront dans notre r é seau
*/
}
void technique3 ( ) {
reseau : : Personne p1 { " Bob " } ;
reseau : : Personne p1 { " Bob " } ;
reseau : : Personne p2 { " Domi " } ;
reseau : : Personne p2 { " Domi " } ;
reseau : : Personne p3 { " Anne " } ;
reseau : : Personne p3 { " Anne " } ;
@ -92,39 +30,45 @@ void technique3(){
reseau : : Personne p13 { " Morgane " } ;
reseau : : Personne p13 { " Morgane " } ;
reseau : : Personne p14 { " Thibault " } ;
reseau : : Personne p14 { " Thibault " } ;
reseau : : Personne p15 { " Gwen " } ;
reseau : : Personne p15 { " Gwen " } ;
list < reseau : : Contact * > Contacts ;
list < Contact * > Contacts ;
// cout << "----------\n";
/*
reseau : : Contact c1 { p1 } ;
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 ) ;
Contacts . push_back ( & c1 ) ;
reseau : : Contact c2 { p2 } ;
Contact c2 { p2 } ;
Contacts . push_back ( & c2 ) ;
Contacts . push_back ( & c2 ) ;
reseau: : Contact c3 { p3 } ;
Contact c3 { p3 } ;
Contacts . push_back ( & c3 ) ;
Contacts . push_back ( & c3 ) ;
reseau: : Contact c4 { p4 } ;
Contact c4 { p4 } ;
Contacts . push_back ( & c4 ) ;
Contacts . push_back ( & c4 ) ;
reseau: : Contact c5 { p5 } ;
Contact c5 { p5 } ;
Contacts . push_back ( & c5 ) ;
Contacts . push_back ( & c5 ) ;
reseau: : Contact c6 { p6 } ;
Contact c6 { p6 } ;
Contacts . push_back ( & c6 ) ;
Contacts . push_back ( & c6 ) ;
reseau: : Contact c7 { p7 } ;
Contact c7 { p7 } ;
Contacts . push_back ( & c7 ) ;
Contacts . push_back ( & c7 ) ;
reseau: : Contact c8 { p8 } ;
Contact c8 { p8 } ;
Contacts . push_back ( & c8 ) ;
Contacts . push_back ( & c8 ) ;
reseau: : Contact c9 { p9 } ;
Contact c9 { p9 } ;
Contacts . push_back ( & c9 ) ;
Contacts . push_back ( & c9 ) ;
reseau: : Contact c10 { p10 } ;
Contact c10 { p10 } ;
Contacts . push_back ( & c10 ) ;
Contacts . push_back ( & c10 ) ;
reseau: : Contact c11 { p11 } ;
Contact c11 { p11 } ;
Contacts . push_back ( & c11 ) ;
Contacts . push_back ( & c11 ) ;
reseau: : Contact c12 { p12 } ;
Contact c12 { p12 } ;
Contacts . push_back ( & c12 ) ;
Contacts . push_back ( & c12 ) ;
reseau: : Contact c13 { p13 } ;
Contact c13 { p13 } ;
Contacts . push_back ( & c13 ) ;
Contacts . push_back ( & c13 ) ;
reseau: : Contact c14 { p14 } ;
Contact c14 { p14 } ;
Contacts . push_back ( & c14 ) ;
Contacts . push_back ( & c14 ) ;
reseau: : Contact c15 { p15 } ;
Contact c15 { p15 } ;
Contacts . push_back ( & c15 ) ;
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 ( p2 ) ;
c1 . ajouterContact ( p5 ) ;
c1 . ajouterContact ( p5 ) ;
c1 . ajouterContact ( p4 ) ;
c1 . ajouterContact ( p4 ) ;
@ -148,165 +92,121 @@ void technique3(){
c14 . ajouterContact ( p13 ) ;
c14 . ajouterContact ( p13 ) ;
c15 . ajouterContact ( p9 ) ;
c15 . ajouterContact ( p9 ) ;
int choix , choix2 , choix3 , persChoix ;
vector < Contact > Repertoire = { c1 , c2 , c3 , c4 , c5 , c6 , c7 , c8 , c9 , c10 , c11 , c12 , c13 , c14 , c15 } ;
int i = 1 ;
Repertoire [ i ] . afficherContactDirect ( ) ;
cout < < " \n --------------------------------------------------------------- \n | Technique n°3 (1) | Technique n°2 (2) | Sortir (3) | \n --------------------------------------------------------------- \n \n --> " ;
/*
D é but du menu et initialisation des variables qu ' on utilisera pour chaque partie de celui - ci
*/
int choix , choix2 , choix3 , persChoix , persDest , persEnvoie ;
cout < < " \n --------------------------------------------------------------- \n | Technique n°1 (1) | Technique n°3 (2) | Sortir (3) | \n --------------------------------------------------------------- \n \n --> " ;
cin > > choix ;
cin > > choix ;
switch ( choix ) {
switch ( choix ) {
case 1 :
case 1 :
case 2 :
cout < < " \n ------------------------------------------------------------- \n | Cas global (1) | Cas individuel (2) | Retour (3) | \n ------------------------------------------------------------- \n \n --> " ;
cout < < " \n ------------------------------------------------------------- \n | Cas global (1) | Cas individuel (2) | Retour (3) | \n ------------------------------------------------------------- \n \n --> " ;
cin > > choix2 ;
cin > > choix2 ;
switch ( 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 1 :
case 2 :
case 2 :
cout < < " \n ------------------------------------------------------------------- \n | Contact Direct (1) | Contact Indirect (2) | Retour (3) | \n ------------------------------------------------------------------- \n \n --> " ;
cout < < " \n ------------------------------------------------------------------- \n | Contact Direct (1) | Contact Indirect (2) | Retour (3) | \n ------------------------------------------------------------------- \n \n --> " ;
cin > > choix3 ;
cin > > choix3 ;
switch ( 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 1 :
case 2 :
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 ) {
if ( choix2 = = 2 ) {
cout < < " \n Choisissez la personne que vous voulez regarder : \n \n -------------------- \n (1) \t Bob \n (2) \t Domi \n (3) \t Anne \n (4) \t Elie \n (5) \t Cali \n (6) \t Samuel \n (7) \t Elena \n (8) \t Baptiste \n (9) \t Franck \n (10) \t Agathe \n (11) \t Louna \n (12) \t Theo \n (13) \t Morgane \n (14) \t Thibault \n (15) \t Gwen \n -------------------- \n \n Tapez le numéro de la personne : " ;
cout < < " \n Choisissez la personne que vous voulez regarder : \n \n -------------------- \n (1) \t Bob \n (2) \t Domi \n (3) \t Anne \n (4) \t Elie \n (5) \t Cali \n (6) \t Samuel \n (7) \t Elena \n (8) \t Baptiste \n (9) \t Franck \n (10) \t Agathe \n (11) \t Louna \n (12) \t Theo \n (13) \t Morgane \n (14) \t Thibault \n (15) \t Gwen \n -------------------- \n \n Tapez le numéro de la personne : " ;
cin > > persChoix ;
cin > > persChoix ;
cout < < " \n " ;
cout < < " \n " ;
/*
On applique en fonction de notre choix3 les m é thodes voulu , afin d ' é viter des r é p é titions dans les case .
*/
switch ( choix3 ) {
switch ( choix3 ) {
case 1 :
case 1 :
if ( persChoix = = 1 )
/*
c1 . afficherContactDirect ( ) ;
En fonction de la personne choisi avec la variable persChoix , il affiche ses contacts directs
if ( persChoix = = 2 )
*/
c2 . afficherContactDirect ( ) ;
Repertoire [ persChoix - 1 ] . 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 ;
break ;
case 2 :
case 2 :
if ( persChoix = = 1 )
/*
c1 . afficherContactIndirect ( Contacts ) ;
En fonction de la personne choisi avec la variable persChoix , il affiche sa propagation
if ( persChoix = = 2 )
*/
c2 . afficherContactIndirect ( Contacts ) ;
Repertoire [ persChoix - 1 ] . 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 ;
break ;
}
}
}
}
else {
else {
switch ( choix3 ) {
switch ( choix3 ) {
case 1 :
case 1 :
/*
c1 . afficherContactDirect ( ) ;
On affiche les contacts directs de tout le r é seau
c2 . afficherContactDirect ( ) ;
*/
c3 . afficherContactDirect ( ) ;
for ( long unsigned int i = 0 ; i < Repertoire . size ( ) ; i + + ) {
c4 . afficherContactDirect ( ) ;
Repertoire [ i ] . afficherContactDirect ( ) ;
c5 . afficherContactDirect ( ) ;
}
c6 . afficherContactDirect ( ) ;
c7 . afficherContactDirect ( ) ;
c8 . afficherContactDirect ( ) ;
c9 . afficherContactDirect ( ) ;
c10 . afficherContactDirect ( ) ;
c11 . afficherContactDirect ( ) ;
c12 . afficherContactDirect ( ) ;
c13 . afficherContactDirect ( ) ;
c14 . afficherContactDirect ( ) ;
c15 . afficherContactDirect ( ) ;
break ;
break ;
case 2 :
case 2 :
/*
c1 . afficherContactIndirect ( Contacts ) ;
On affiche la propagation de tout le r é seau
c2 . afficherContactIndirect ( Contacts ) ;
*/
c3 . afficherContactIndirect ( Contacts ) ;
for ( long unsigned int i = 0 ; i < Repertoire . size ( ) ; i + + ) {
c4 . afficherContactIndirect ( Contacts ) ;
Repertoire [ i ] . 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 ;
}
}
}
}
break ;
break ;
case 3 :
case 3 :
technique3 ( ) ;
/*
les deux prochains case sont l à pour appeler r é cursivement le main et donc notre menu
*/
main ( ) ;
break ;
break ;
}
}
break ;
break ;
case 3 :
case 3 :
technique3 ( ) ;
main ( ) ;
break ;
break ;
}
}
// sleep_for(8s);
/*
// system("clear");
On attend 8 secondes apr è s l ' affichage de nos commandes puis on effache tout , pour avoir un ternimal vide entre chaque utilisation
technique3 ( ) ;
*/
main ( ) ;
break ;
case 2 :
cout < < " \n Choisissez la personne qui envoie : \n \n -------------------- \n (1) \t Bob \n (2) \t Domi \n (3) \t Anne \n (4) \t Elie \n (5) \t Cali \n (6) \t Samuel \n (7) \t Elena \n (8) \t Baptiste \n (9) \t Franck \n (10) \t Agathe \n (11) \t Louna \n (12) \t Theo \n (13) \t Morgane \n (14) \t Thibault \n (15) \t Gwen \n -------------------- \n \n Tapez le numéro de la personne : " ;
cin > > persEnvoie ;
cout < < " \n " ;
cout < < " \n Choisissez le destinataire : \n \n -------------------- \n (1) \t Bob \n (2) \t Domi \n (3) \t Anne \n (4) \t Elie \n (5) \t Cali \n (6) \t Samuel \n (7) \t Elena \n (8) \t Baptiste \n (9) \t Franck \n (10) \t Agathe \n (11) \t Louna \n (12) \t Theo \n (13) \t Morgane \n (14) \t Thibault \n (15) \t Gwen \n -------------------- \n \n Tapez le numéro de la personne : " ;
cin > > persDest ;
cout < < " \n " ;
Repertoire [ persEnvoie - 1 ] . peutCommuniquer ( Repertoire [ persDest - 1 ] ) ;
main ( ) ;
break ;
break ;
case 3 :
case 3 :
/* le return sert pour arrêter le programme lorsqu'on demande l'exit sur le premier menu*/
exit ( 0 ) ; /* */
break ;
break ;
}
}
}
int main ( ) {
technique1 ( ) ;
// technique3();
return 0 ;
}
}