Skip to content

Commit ada6cc3

Browse files
committed
update
1 parent be6fc3c commit ada6cc3

File tree

2 files changed

+114
-107
lines changed

2 files changed

+114
-107
lines changed

header/Menu.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace Manage
1313
public:
1414
Menu(){}
1515
~Menu(){}
16+
void printMenu();
1617
int check_input_value(int limit_inf, int limit_max);
1718
void launch_programm_manage_annuaire(string fileContactPrivate, string fileContactPro);
1819

sources/menu.cpp

Lines changed: 113 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -5,117 +5,123 @@
55
namespace Manage
66
{
77

8-
int Menu::check_input_value(int limit_inf, int limit_max)
9-
{
10-
int opc;
11-
bool aux = true;
12-
cin.exceptions(std::istream::failbit);
13-
do {
14-
try
15-
{
16-
cout << "Veuillez saisir un entier compris entre "
17-
<< limit_inf
18-
<< " et "
19-
<< limit_max
20-
<< endl;
21-
cin >> opc;
22-
aux = true;
23-
}
24-
catch (std::ios_base::failure &fail)
25-
{
26-
aux = false;
27-
cout << "Veuillez saisir une option valide." << endl;
28-
cin.clear();
29-
std::string tmp;
30-
getline(cin, tmp);
31-
}
32-
} while (aux == false || (limit_inf < opc && opc > limit_max));
33-
return opc;
34-
}
8+
void Menu::printMenu()
9+
{
10+
cout << endl
11+
<< " ----------------------- MENU -----------------------" << endl
12+
<< endl;
13+
cout << "1. Voir le contenu de l'annuaire " << endl;
14+
cout << "2. Voir le contenu de l'annuaire prive" << endl;
15+
cout << "3. Voir le contenu de l'annuaire pro" << endl;
16+
cout << "4. Ajouter un Contact prive a l'annuaire" << endl;
17+
cout << "5. Ajouter un Contact professionnel a l'annuaire" << endl;
18+
cout << "6. Rechercher un Contact par son numero unique" << endl;
19+
cout << "7. Rechercher un Contact par son nom" << endl;
20+
cout << "8. Rechercher un Contact par son prenom" << endl;
21+
cout << "9. Rechercher un Contact par son code postale" << endl;
22+
cout << "10. Rechercher un contact par son Departement" << endl;
23+
cout << "11. Rechercher un contact par sa ville" << endl;
24+
cout << "12. Rechercher un contact par son email" << endl;
25+
cout << "13. Supprimer un contact par son identifiant" << endl;
26+
cout << "14. Modifier un contact par son identifiant" << endl;
27+
cout << "0. Quitter" << endl;
28+
cout << endl
29+
<< "Votre choix : " << endl;
30+
}
31+
int Menu::check_input_value(int limit_inf, int limit_max)
32+
{
33+
int opc;
34+
bool aux = true;
35+
cin.exceptions(std::istream::failbit);
36+
do
37+
{
38+
try
39+
{
40+
cout << "Veuillez saisir un entier compris entre "
41+
<< limit_inf
42+
<< " et "
43+
<< limit_max
44+
<< endl;
45+
cin >> opc;
46+
aux = true;
47+
}
48+
catch (std::ios_base::failure &fail)
49+
{
50+
aux = false;
51+
cout << "Veuillez saisir une option valide." << endl;
52+
cin.clear();
53+
std::string tmp;
54+
getline(cin, tmp);
55+
}
56+
} while (aux == false || (limit_inf < opc && opc > limit_max));
57+
return opc;
58+
}
3559

36-
void Menu::launch_programm_manage_annuaire(string fileContactPrivate, string fileContactPro)
37-
{
60+
void Menu::launch_programm_manage_annuaire(string fileContactPrivate, string fileContactPro)
61+
{
3862

39-
Console * console = new Console();
40-
console->load_datas(fileContactPrivate, fileContactPro);
63+
Console *console = new Console();
64+
console->load_datas(fileContactPrivate, fileContactPro);
4165

42-
int menu = -1;
66+
int menu = -1;
4367

44-
do
45-
{
46-
menu = -1;
47-
cout<< endl << " ----------------------- MENU -----------------------" <<endl <<endl;
48-
cout<<"1. Voir le contenu de l'annuaire " <<endl;
49-
cout<<"2. Voir le contenu de l'annuaire prive" <<endl;
50-
cout<<"3. Voir le contenu de l'annuaire pro" <<endl;
51-
cout<<"4. Ajouter un Contact prive a l'annuaire" <<endl;
52-
cout<<"5. Ajouter un Contact professionnel a l'annuaire" <<endl;
53-
cout<<"6. Rechercher un Contact par son numero unique" <<endl;
54-
cout<<"7. Rechercher un Contact par son nom" <<endl;
55-
cout<<"8. Rechercher un Contact par son prenom" <<endl;
56-
cout<<"9. Rechercher un Contact par son code postale" <<endl;
57-
cout<<"10. Rechercher un contact par son Departement" <<endl;
58-
cout<<"11. Rechercher un contact par sa ville" <<endl;
59-
cout<<"12. Rechercher un contact par son email" <<endl;
60-
cout<<"13. Supprimer un contact par son identifiant" <<endl;
61-
cout<<"14. Modifier un contact par son identifiant" <<endl;
62-
cout<<"0. Quitter" <<endl;
63-
cout<<endl <<"Votre choix : " <<endl;
68+
do
69+
{
70+
menu = -1;
71+
printMenu();
72+
menu = check_input_value(1, 14);
73+
cout << endl;
6474

65-
menu = check_input_value(1, 12);
66-
cout<<endl;
67-
68-
switch(menu)
69-
{
70-
case 0 :
71-
break;
72-
case 1 :
73-
console->afficher_annuaire();
74-
break;
75-
case 2 :
76-
console->afficher_annuaire_prive();
77-
break;
78-
case 3 :
79-
console->afficher_annuaire_pros();
80-
break;
81-
case 4 :
82-
console->ajouter_contact_prive();
83-
break;
84-
case 5 :
85-
console->ajouter_contact_professionnel();
86-
break;
87-
case 6 :
88-
console->rechercher_contact_pid();
89-
break;
90-
case 7 :
91-
console->rechercher_contact_nom();
92-
break;
93-
case 8 :
94-
console->rechercher_contact_prenom();
95-
break;
96-
case 9 :
97-
console->rechercher_contact_code_postale();
98-
break;
99-
case 10 :
100-
console->rechercher_contact_departement();
101-
break;
102-
case 11 :
103-
console->rechercher_contact_ville();
104-
break;
105-
case 12 :
106-
console->rechercher_contact_email();
107-
break;
108-
case 13 :
109-
console->supprimer_contact_pid();
110-
break;
111-
case 14 :
112-
console->modifier_contact_pid();
113-
break;
114-
}
115-
}
116-
while (menu != 0);
117-
delete console;
118-
console = nullptr;
119-
}
75+
switch (menu)
76+
{
77+
case 0:
78+
break;
79+
case 1:
80+
console->afficher_annuaire();
81+
break;
82+
case 2:
83+
console->afficher_annuaire_prive();
84+
break;
85+
case 3:
86+
console->afficher_annuaire_pros();
87+
break;
88+
case 4:
89+
console->ajouter_contact_prive();
90+
break;
91+
case 5:
92+
console->ajouter_contact_professionnel();
93+
break;
94+
case 6:
95+
console->rechercher_contact_pid();
96+
break;
97+
case 7:
98+
console->rechercher_contact_nom();
99+
break;
100+
case 8:
101+
console->rechercher_contact_prenom();
102+
break;
103+
case 9:
104+
console->rechercher_contact_code_postale();
105+
break;
106+
case 10:
107+
console->rechercher_contact_departement();
108+
break;
109+
case 11:
110+
console->rechercher_contact_ville();
111+
break;
112+
case 12:
113+
console->rechercher_contact_email();
114+
break;
115+
case 13:
116+
console->supprimer_contact_pid();
117+
break;
118+
case 14:
119+
console->modifier_contact_pid();
120+
break;
121+
}
122+
} while (menu != 0);
123+
delete console;
124+
console = nullptr;
125+
}
120126

121127
}

0 commit comments

Comments
 (0)