Skip to content

Commit 91cd881

Browse files
committed
fix: store return value of SYS_CLEAR() for clarity and consistency
1 parent eb404b3 commit 91cd881

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

src/Menu/MainFunctions.cpp

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "MainFunctions.h"
22

33
void Add_N(AreaList* l) {
4-
int x1, x2, y1, y2;
4+
int x1, x2, y1, y2, retTmp;
55
string name;
66
cout << Color_Orange << "please enter the name of the area" << Color_Reset
77
<< endl;
@@ -23,20 +23,20 @@ void Add_N(AreaList* l) {
2323
<< name << " (" << x1 << "," << y1 << ") (" << x2 << "," << y2
2424
<< ")" << Color_Yellow << "\n\npress any key to continue" << endl;
2525
getch();
26-
(void)SYS_CLEAR();
26+
retTmp = SYS_CLEAR();
2727
} else {
2828
cout << Color_Red << "\ncouldn't add the area: " << Color_Green_Blue
2929
<< name << " (" << x1 << "," << y1 << ") (" << x2 << "," << y2
3030
<< ")" << Color_Red
3131
<< ", this area already exist with this name or those points"
3232
<< Color_Yellow << "\n\npress any key to continue" << endl;
3333
getch();
34-
(void)SYS_CLEAR();
34+
retTmp = SYS_CLEAR();
3535
}
3636
}
3737

3838
void Add_P(pizzaDataBase* db, KDTree* ap) {
39-
int x1, y1;
39+
int x1, y1, retTmp;
4040
string name;
4141
cout << Color_Orange << "please enter the name of the Pizza shop"
4242
<< Color_Reset << endl;
@@ -54,15 +54,15 @@ void Add_P(pizzaDataBase* db, KDTree* ap) {
5454
<< "here exist a pizza shop already, couldn't add the pizza shop"
5555
<< Color_Yellow << "\n\npress any key to continue" << endl;
5656
getch();
57-
(void)SYS_CLEAR();
57+
retTmp = SYS_CLEAR();
5858
delete temp;
5959
} else if (db->addNewMainBranch(temp)) {
6060
cout << Color_Green
6161
<< "\nsuccessfully added the main pizza shop: " << Color_Green_Blue
6262
<< name << "\nlocation: (" << x1 << "," << y1 << ")"
6363
<< Color_Yellow << "\n\npress any key to continue" << endl;
6464
getch();
65-
(void)SYS_CLEAR();
65+
retTmp = SYS_CLEAR();
6666
} else {
6767
cout << Color_Red
6868
<< "\ncouldn't add the main pizza shop: " << Color_Green_Blue
@@ -72,12 +72,12 @@ void Add_P(pizzaDataBase* db, KDTree* ap) {
7272
ap->deleteNode(temp->getPoint());
7373
delete temp;
7474
getch();
75-
(void)SYS_CLEAR();
75+
retTmp = SYS_CLEAR();
7676
}
7777
}
7878

7979
void Add_Br(pizzaDataBase* db, KDTree* ap) {
80-
int x1, y1;
80+
int x1, y1, retTmp;
8181
string name, mainName;
8282
cout << Color_Orange << "please enter the name of the branch Pizza shop"
8383
<< Color_Reset << endl;
@@ -98,15 +98,15 @@ void Add_Br(pizzaDataBase* db, KDTree* ap) {
9898
<< "here exist a pizza shop already, couldn't add the pizza shop"
9999
<< Color_Yellow << "\n\npress any key to continue" << endl;
100100
getch();
101-
(void)SYS_CLEAR();
101+
retTmp = SYS_CLEAR();
102102
delete temp;
103103
} else if (db->addNewBranch(temp)) {
104104
cout << Color_Green << "\nsuccessfully added the branch pizza shop: "
105105
<< Color_Green_Blue << name << "\n location: (" << x1 << "," << y1
106106
<< ")\nmain shop: " << mainName << Color_Yellow
107107
<< "\n\npress any key to continue" << endl;
108108
getch();
109-
(void)SYS_CLEAR();
109+
retTmp = SYS_CLEAR();
110110
} else {
111111
cout << Color_Red
112112
<< "\ncouldn't add the branch pizza shop: " << Color_Green_Blue
@@ -118,12 +118,12 @@ void Add_Br(pizzaDataBase* db, KDTree* ap) {
118118
ap->deleteNode(temp->getPoint());
119119
delete temp;
120120
getch();
121-
(void)SYS_CLEAR();
121+
retTmp = SYS_CLEAR();
122122
}
123123
}
124124

125125
void Del_Br(pizzaDataBase* db, KDTree* ap) {
126-
int x1, y1;
126+
int x1, y1, retTmp;
127127
cout << Color_Orange
128128
<< "entering the location of the shop that you want to "
129129
"delete\n\nplease enter the x"
@@ -142,12 +142,12 @@ void Del_Br(pizzaDataBase* db, KDTree* ap) {
142142
<< "(" << x1 << ", " << y1 << ")" << Color_Yellow
143143
<< "\n\npress any key to continue" << endl;
144144
getch();
145-
(void)SYS_CLEAR();
145+
retTmp = SYS_CLEAR();
146146
} else {
147147
cout << Color_Red << "\ncouldn't delete the pizza shop in this location"
148148
<< Color_Yellow << "\n\npress any key to continue" << endl;
149149
getch();
150-
(void)SYS_CLEAR();
150+
retTmp = SYS_CLEAR();
151151
}
152152
}
153153

@@ -173,7 +173,7 @@ void List_P(KDTree* ap, AreaList* l) {
173173

174174
cout << Color_Yellow << "\n\npress any key to continue" << endl;
175175
getch();
176-
(void)SYS_CLEAR();
176+
int retTmp = SYS_CLEAR();
177177
}
178178

179179
void List_Brs(pizzaDataBase* db) {
@@ -188,7 +188,7 @@ void List_Brs(pizzaDataBase* db) {
188188

189189
cout << Color_Yellow << "\n\npress any key to continue" << endl;
190190
getch();
191-
(void)SYS_CLEAR();
191+
int retTmp = SYS_CLEAR();
192192
}
193193

194194
void Near_P(KDTree* ap) {
@@ -254,7 +254,7 @@ void Avail_P(KDTree* ap) {
254254

255255
cout << Color_Yellow << "\n\npress any key to continue" << endl;
256256
getch();
257-
(void)SYS_CLEAR();
257+
int retTmp = SYS_CLEAR();
258258
}
259259

260260
void Most_Brs(pizzaDataBase* db) {

src/Menu/menu.cpp

+14-13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
void mainMenu(pizzaDataBase* db, AreaList* l, KDTree* ap) {
44
string act;
5+
int returnVal;
56
while (1) {
67
cout << Color_Yellow_Dark
78
<< "---------------------------------------------------------"
@@ -43,48 +44,48 @@ void mainMenu(pizzaDataBase* db, AreaList* l, KDTree* ap) {
4344
<< Color_Reset << endl;
4445
cin >> act;
4546
if (act == "1" || act == "Add-N" || act == "add-n") {
46-
(void)SYS_CLEAR();
47+
returnVal = SYS_CLEAR();
4748
Add_N(l);
4849
} else if (act == "2" || act == "Add-P" || act == "add-p") {
49-
(void)SYS_CLEAR();
50+
returnVal = SYS_CLEAR();
5051
Add_P(db, ap);
5152
} else if (act == "3" || act == "Add-Br" || act == "add-br") {
52-
(void)SYS_CLEAR();
53+
returnVal = SYS_CLEAR();
5354
Add_Br(db, ap);
5455
} else if (act == "4" || act == "Del-Br" || act == "del-br") {
55-
(void)SYS_CLEAR();
56+
returnVal = SYS_CLEAR();
5657
Del_Br(db, ap);
5758
} else if (act == "5" || act == "List-P" || act == "list-p") {
58-
(void)SYS_CLEAR();
59+
returnVal = SYS_CLEAR();
5960
List_P(ap, l);
6061
} else if (act == "6" || act == "List-Brs" || act == "list-brs") {
61-
(void)SYS_CLEAR();
62+
returnVal = SYS_CLEAR();
6263
List_Brs(db);
6364
} else if (act == "7" || act == "Near-P" || act == "near-p") {
64-
(void)SYS_CLEAR();
65+
returnVal = SYS_CLEAR();
6566
Near_P(ap);
6667
} else if (act == "8" || act == "Near-Br" || act == "near-br") {
67-
(void)SYS_CLEAR();
68+
returnVal = SYS_CLEAR();
6869
Near_Br(ap, db);
6970
} else if (act == "9" || act == "Avail-P" || act == "avail-p") {
70-
(void)SYS_CLEAR();
71+
returnVal = SYS_CLEAR();
7172
Avail_P(ap);
7273
} else if (act == "10" || act == "Most-Brs" || act == "most-brs") {
73-
(void)SYS_CLEAR();
74+
returnVal = SYS_CLEAR();
7475
Most_Brs(db);
7576
} else if (act == "11" || act == "Undo" || act == "undo") {
76-
(void)SYS_CLEAR();
77+
returnVal = SYS_CLEAR();
7778
cout << "12\n" << endl;
7879
} else if (act == "0" || act == "Exit" || act == "exit") {
79-
(void)SYS_CLEAR();
80+
returnVal = SYS_CLEAR();
8081
cout << Color_Deep_Pink
8182
<< "program ended, press any key to close the program\n"
8283
<< endl;
8384
getch();
8485
cout << Color_Reset << endl;
8586
break;
8687
} else {
87-
(void)SYS_CLEAR();
88+
returnVal = SYS_CLEAR();
8889
cout << Color_Red << "please enter a valid option\n" << endl;
8990
}
9091
}

0 commit comments

Comments
 (0)