SAÉ 2.02
Test doc
main.cpp
Go to the documentation of this file.
1 
8 #include <iostream>
9 #include <thread> /* on récupère thread afin de faire un sleep pour l'esthétique du menu */
10 #include "Personne.hpp"
11 #include"Contact.hpp"
12 
13 using namespace std;
14 using namespace reseau;
15 using this_thread::sleep_for;
16 
26 int main(){
27  /*
28  On crée chaque personne qui seront dans notre réseau
29  */
30  Personne p1{"Bob"};
31  Personne p2{"Domi"};
32  Personne p3{"Anne"};
33  Personne p4{"Elie"};
34  Personne p5{"Cali"};
35  Personne p6{"Samuel"};
36  Personne p7{"Elena"};
37  Personne p8{"Baptiste"};
38  Personne p9{"Franck"};
39  Personne p10{"Agathe"};
40  Personne p11{"Louna"};
41  Personne p12{"Theo"};
42  Personne p13{"Morgane"};
43  Personne p14{"Thibault"};
44  Personne p15{"Gwen"};
45  list<Contact*> Contacts;
46  // cout << "----------\n";
47  /*
48  On crée les contacts en mettant leur propiétaire, on ajoute ensuite chaque contact dans une liste juste après leur construction
49  */
50  Contact c1{p1};
51  Contacts.push_back(&c1);
52  Contact c2{p2};
53  Contacts.push_back(&c2);
54  Contact c3{p3};
55  Contacts.push_back(&c3);
56  Contact c4{p4};
57  Contacts.push_back(&c4);
58  Contact c5{p5};
59  Contacts.push_back(&c5);
60  Contact c6{p6};
61  Contacts.push_back(&c6);
62  Contact c7{p7};
63  Contacts.push_back(&c7);
64  Contact c8{p8};
65  Contacts.push_back(&c8);
66  Contact c9{p9};
67  Contacts.push_back(&c9);
68  Contact c10{p10};
69  Contacts.push_back(&c10);
70  Contact c11{p11};
71  Contacts.push_back(&c11);
72  Contact c12{p12};
73  Contacts.push_back(&c12);
74  Contact c13{p13};
75  Contacts.push_back(&c13);
76  Contact c14{p14};
77  Contacts.push_back(&c14);
78  Contact c15{p15};
79  Contacts.push_back(&c15);
80  // cout << "----------\n";
81  /*
82  On place les contacts directs dans une liste de personne qui correspond au répertoire de chaque personne
83  */
84  c1.ajouterContact(p2);
85  c1.ajouterContact(p5);
86  c1.ajouterContact(p4);
87  c3.ajouterContact(p1);
88  c3.ajouterContact(p2);
89  c4.ajouterContact(p5);
90  c4.ajouterContact(p6);
91  c5.ajouterContact(p4);
92  c6.ajouterContact(p7);
93  c6.ajouterContact(p9);
94  c7.ajouterContact(p3);
95  c8.ajouterContact(p2);
96  c9.ajouterContact(p6);
97  c9.ajouterContact(p11);
98  c10.ajouterContact(p7);
99  c10.ajouterContact(p8);
100  c11.ajouterContact(p15);
101  c12.ajouterContact(p10);
102  c13.ajouterContact(p11);
103  c14.ajouterContact(p12);
104  c14.ajouterContact(p13);
105  c15.ajouterContact(p9);
106  // cout << "----------\n";
107  // c1.rechercher(p3);
108  // c1.rechercher(p2);
109  // c1.rechercher(p5);
110  // cout << "----------\n";
111 
112 
113  /*
114  Début du menu et initialisation des variables qu'on utilisera pour chaque partie de celui-ci
115  */
116  int choix, choix2, choix3, persChoix;
117 
118 
119  cout <<"\n ---------------------------------------------------------------\n | Technique n°3 (1) | Technique n°2 (2) | Sortir (3) |\n ---------------------------------------------------------------\n\n--> ";
120  cin >> choix;
121  switch(choix) {
122  /*
123  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
124  */
125  case 1 :
126  case 2 :
127 
128  cout << "\n -------------------------------------------------------------\n | Cas global (1) | Cas individuel (2) | Retour (3) |\n -------------------------------------------------------------\n\n--> ";
129  cin >> choix2;
130  switch(choix2) {
131  /*
132  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
133  */
134  case 1:
135  case 2:
136 
137  cout <<"\n -------------------------------------------------------------------\n | Contact Direct (1) | Contact Indirect (2) | Retour (3) |\n -------------------------------------------------------------------\n\n--> ";
138  cin >> choix3;
139  switch(choix3) {
140  /*
141  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
142  */
143  case 1:
144  case 2:
145 
146  /*
147  On applique en fonction de notre choix2 les méthodes et l'affichage voulu, afin d'éviter des répétitions dans les case.
148  */
149  if(choix2==2){
150 
151  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 : ";
152  cin >> persChoix ;
153  cout << "\n";
154 
155  /*
156  On applique en fonction de notre choix3 les méthodes voulu, afin d'éviter des répétitions dans les case.
157  */
158  switch(choix3) {
159  case 1:
160  /*
161  En fonction de la personne choisi avec la variable persChoix, il affiche ses contacts directs
162  */
163  if(persChoix==1)
164  c1.afficherContactDirect();
165  if(persChoix==2)
166  c2.afficherContactDirect();
167  if(persChoix==3)
168  c3.afficherContactDirect();
169  if(persChoix==4)
170  c4.afficherContactDirect();
171  if(persChoix==5)
172  c5.afficherContactDirect();
173  if(persChoix==6)
174  c6.afficherContactDirect();
175  if(persChoix==7)
176  c7.afficherContactDirect();
177  if(persChoix==8)
178  c8.afficherContactDirect();
179  if(persChoix==9)
180  c9.afficherContactDirect();
181  if(persChoix==10)
182  c10.afficherContactDirect();
183  if(persChoix==11)
184  c11.afficherContactDirect();
185  if(persChoix==12)
186  c12.afficherContactDirect();
187  if(persChoix==13)
188  c13.afficherContactDirect();
189  if(persChoix==14)
190  c14.afficherContactDirect();
191  if(persChoix==15)
192  c15.afficherContactDirect();
193  break;
194  case 2:
195  /*
196  En fonction de la personne choisi avec la variable persChoix, il affiche sa propagation
197  */
198  if(persChoix==1)
199  c1.afficherContactIndirect(Contacts);
200  if(persChoix==2)
201  c2.afficherContactIndirect(Contacts);
202  if(persChoix==3)
203  c3.afficherContactIndirect(Contacts);
204  if(persChoix==4)
205  c4.afficherContactIndirect(Contacts);
206  if(persChoix==5)
207  c5.afficherContactIndirect(Contacts);
208  if(persChoix==6)
209  c6.afficherContactIndirect(Contacts);
210  if(persChoix==7)
211  c7.afficherContactIndirect(Contacts);
212  if(persChoix==8)
213  c8.afficherContactIndirect(Contacts);
214  if(persChoix==9)
215  c9.afficherContactIndirect(Contacts);
216  if(persChoix==10)
217  c10.afficherContactIndirect(Contacts);
218  if(persChoix==11)
219  c11.afficherContactIndirect(Contacts);
220  if(persChoix==12)
221  c12.afficherContactIndirect(Contacts);
222  if(persChoix==13)
223  c13.afficherContactIndirect(Contacts);
224  if(persChoix==14)
225  c14.afficherContactIndirect(Contacts);
226  if(persChoix==15)
227  c15.afficherContactIndirect(Contacts);
228  break;
229  }
230  }
231  else{
232  switch(choix3){
233  case 1:
234  /*
235  On affiche les contacts directs de tout le réseau
236  */ */
237  c1.afficherContactDirect();
238  c2.afficherContactDirect();
239  c3.afficherContactDirect();
240  c4.afficherContactDirect();
241  c5.afficherContactDirect();
242  c6.afficherContactDirect();
243  c7.afficherContactDirect();
244  c8.afficherContactDirect();
245  c9.afficherContactDirect();
246  c10.afficherContactDirect();
247  c11.afficherContactDirect();
248  c12.afficherContactDirect();
249  c13.afficherContactDirect();
250  c14.afficherContactDirect();
251  c15.afficherContactDirect();
252 
253  break;
254  case 2:
255  /*
256  On affiche la propagation de tout le réseau
257  */
258  c1.afficherContactIndirect(Contacts);
259  c2.afficherContactIndirect(Contacts);
260  c3.afficherContactIndirect(Contacts);
261  c4.afficherContactIndirect(Contacts);
262  c5.afficherContactIndirect(Contacts);
263  c6.afficherContactIndirect(Contacts);
264  c7.afficherContactIndirect(Contacts);
265  c8.afficherContactIndirect(Contacts);
266  c9.afficherContactIndirect(Contacts);
267  c10.afficherContactIndirect(Contacts);
268  c11.afficherContactIndirect(Contacts);
269  c12.afficherContactIndirect(Contacts);
270  c13.afficherContactIndirect(Contacts);
271  c14.afficherContactIndirect(Contacts);
272  c15.afficherContactIndirect(Contacts);
273 
274  break;
275  }
276  }
277  break;
278 
279  case 3:
280  /*
281  les deux prochains case sont là pour appeler récursivement le main et donc notre menu
282  */
283  main();
284  break;
285  }
286  break;
287  case 3:
288 
289  main();
290  break;
291  }
292  /*
293  On attend 8 secondes après l'affichage de nos commandes puis on effache tout, pour avoir un ternimal vide entre chaque utilisation
294  */
295  sleep_for(8s);
296  system("clear");
297  main();
298  break;
299  case 3 :
300  /* le return sert pour arrêter le programme lorsqu'on demande l'exit sur le premier menu*/
301  return 0;
302  break;
303  }
304 
305 }
306 
Contient des variables, des constantes et divers types de données relatifs à notre classe Contact...
int main()
Main divisé en deux partie :
Definition: main.cpp:26
Contient des variables, des constantes et divers types de données relatifs à notre classe Personne...