Skip to content

Commit

Permalink
fix: store return value of SYS_CLEAR() for clarity and consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-MRF-Dev committed Jan 16, 2025
1 parent eb404b3 commit 91cd881
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
34 changes: 17 additions & 17 deletions src/Menu/MainFunctions.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "MainFunctions.h"

void Add_N(AreaList* l) {
int x1, x2, y1, y2;
int x1, x2, y1, y2, retTmp;
string name;
cout << Color_Orange << "please enter the name of the area" << Color_Reset
<< endl;
Expand All @@ -23,20 +23,20 @@ void Add_N(AreaList* l) {
<< name << " (" << x1 << "," << y1 << ") (" << x2 << "," << y2
<< ")" << Color_Yellow << "\n\npress any key to continue" << endl;
getch();
(void)SYS_CLEAR();
retTmp = SYS_CLEAR();
} else {
cout << Color_Red << "\ncouldn't add the area: " << Color_Green_Blue
<< name << " (" << x1 << "," << y1 << ") (" << x2 << "," << y2
<< ")" << Color_Red
<< ", this area already exist with this name or those points"
<< Color_Yellow << "\n\npress any key to continue" << endl;
getch();
(void)SYS_CLEAR();
retTmp = SYS_CLEAR();
}
}

void Add_P(pizzaDataBase* db, KDTree* ap) {
int x1, y1;
int x1, y1, retTmp;
string name;
cout << Color_Orange << "please enter the name of the Pizza shop"
<< Color_Reset << endl;
Expand All @@ -54,15 +54,15 @@ void Add_P(pizzaDataBase* db, KDTree* ap) {
<< "here exist a pizza shop already, couldn't add the pizza shop"
<< Color_Yellow << "\n\npress any key to continue" << endl;
getch();
(void)SYS_CLEAR();
retTmp = SYS_CLEAR();
delete temp;
} else if (db->addNewMainBranch(temp)) {
cout << Color_Green
<< "\nsuccessfully added the main pizza shop: " << Color_Green_Blue
<< name << "\nlocation: (" << x1 << "," << y1 << ")"
<< Color_Yellow << "\n\npress any key to continue" << endl;
getch();
(void)SYS_CLEAR();
retTmp = SYS_CLEAR();
} else {
cout << Color_Red
<< "\ncouldn't add the main pizza shop: " << Color_Green_Blue
Expand All @@ -72,12 +72,12 @@ void Add_P(pizzaDataBase* db, KDTree* ap) {
ap->deleteNode(temp->getPoint());
delete temp;
getch();
(void)SYS_CLEAR();
retTmp = SYS_CLEAR();
}
}

void Add_Br(pizzaDataBase* db, KDTree* ap) {
int x1, y1;
int x1, y1, retTmp;
string name, mainName;
cout << Color_Orange << "please enter the name of the branch Pizza shop"
<< Color_Reset << endl;
Expand All @@ -98,15 +98,15 @@ void Add_Br(pizzaDataBase* db, KDTree* ap) {
<< "here exist a pizza shop already, couldn't add the pizza shop"
<< Color_Yellow << "\n\npress any key to continue" << endl;
getch();
(void)SYS_CLEAR();
retTmp = SYS_CLEAR();
delete temp;
} else if (db->addNewBranch(temp)) {
cout << Color_Green << "\nsuccessfully added the branch pizza shop: "
<< Color_Green_Blue << name << "\n location: (" << x1 << "," << y1
<< ")\nmain shop: " << mainName << Color_Yellow
<< "\n\npress any key to continue" << endl;
getch();
(void)SYS_CLEAR();
retTmp = SYS_CLEAR();
} else {
cout << Color_Red
<< "\ncouldn't add the branch pizza shop: " << Color_Green_Blue
Expand All @@ -118,12 +118,12 @@ void Add_Br(pizzaDataBase* db, KDTree* ap) {
ap->deleteNode(temp->getPoint());
delete temp;
getch();
(void)SYS_CLEAR();
retTmp = SYS_CLEAR();
}
}

void Del_Br(pizzaDataBase* db, KDTree* ap) {
int x1, y1;
int x1, y1, retTmp;
cout << Color_Orange
<< "entering the location of the shop that you want to "
"delete\n\nplease enter the x"
Expand All @@ -142,12 +142,12 @@ void Del_Br(pizzaDataBase* db, KDTree* ap) {
<< "(" << x1 << ", " << y1 << ")" << Color_Yellow
<< "\n\npress any key to continue" << endl;
getch();
(void)SYS_CLEAR();
retTmp = SYS_CLEAR();
} else {
cout << Color_Red << "\ncouldn't delete the pizza shop in this location"
<< Color_Yellow << "\n\npress any key to continue" << endl;
getch();
(void)SYS_CLEAR();
retTmp = SYS_CLEAR();
}
}

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

cout << Color_Yellow << "\n\npress any key to continue" << endl;
getch();
(void)SYS_CLEAR();
int retTmp = SYS_CLEAR();
}

void List_Brs(pizzaDataBase* db) {
Expand All @@ -188,7 +188,7 @@ void List_Brs(pizzaDataBase* db) {

cout << Color_Yellow << "\n\npress any key to continue" << endl;
getch();
(void)SYS_CLEAR();
int retTmp = SYS_CLEAR();
}

void Near_P(KDTree* ap) {
Expand Down Expand Up @@ -254,7 +254,7 @@ void Avail_P(KDTree* ap) {

cout << Color_Yellow << "\n\npress any key to continue" << endl;
getch();
(void)SYS_CLEAR();
int retTmp = SYS_CLEAR();
}

void Most_Brs(pizzaDataBase* db) {
Expand Down
27 changes: 14 additions & 13 deletions src/Menu/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

void mainMenu(pizzaDataBase* db, AreaList* l, KDTree* ap) {
string act;
int returnVal;
while (1) {
cout << Color_Yellow_Dark
<< "---------------------------------------------------------"
Expand Down Expand Up @@ -43,48 +44,48 @@ void mainMenu(pizzaDataBase* db, AreaList* l, KDTree* ap) {
<< Color_Reset << endl;
cin >> act;
if (act == "1" || act == "Add-N" || act == "add-n") {
(void)SYS_CLEAR();
returnVal = SYS_CLEAR();
Add_N(l);
} else if (act == "2" || act == "Add-P" || act == "add-p") {
(void)SYS_CLEAR();
returnVal = SYS_CLEAR();
Add_P(db, ap);
} else if (act == "3" || act == "Add-Br" || act == "add-br") {
(void)SYS_CLEAR();
returnVal = SYS_CLEAR();
Add_Br(db, ap);
} else if (act == "4" || act == "Del-Br" || act == "del-br") {
(void)SYS_CLEAR();
returnVal = SYS_CLEAR();
Del_Br(db, ap);
} else if (act == "5" || act == "List-P" || act == "list-p") {
(void)SYS_CLEAR();
returnVal = SYS_CLEAR();
List_P(ap, l);
} else if (act == "6" || act == "List-Brs" || act == "list-brs") {
(void)SYS_CLEAR();
returnVal = SYS_CLEAR();
List_Brs(db);
} else if (act == "7" || act == "Near-P" || act == "near-p") {
(void)SYS_CLEAR();
returnVal = SYS_CLEAR();
Near_P(ap);
} else if (act == "8" || act == "Near-Br" || act == "near-br") {
(void)SYS_CLEAR();
returnVal = SYS_CLEAR();
Near_Br(ap, db);
} else if (act == "9" || act == "Avail-P" || act == "avail-p") {
(void)SYS_CLEAR();
returnVal = SYS_CLEAR();
Avail_P(ap);
} else if (act == "10" || act == "Most-Brs" || act == "most-brs") {
(void)SYS_CLEAR();
returnVal = SYS_CLEAR();
Most_Brs(db);
} else if (act == "11" || act == "Undo" || act == "undo") {
(void)SYS_CLEAR();
returnVal = SYS_CLEAR();
cout << "12\n" << endl;
} else if (act == "0" || act == "Exit" || act == "exit") {
(void)SYS_CLEAR();
returnVal = SYS_CLEAR();
cout << Color_Deep_Pink
<< "program ended, press any key to close the program\n"
<< endl;
getch();
cout << Color_Reset << endl;
break;
} else {
(void)SYS_CLEAR();
returnVal = SYS_CLEAR();
cout << Color_Red << "please enter a valid option\n" << endl;
}
}
Expand Down

0 comments on commit 91cd881

Please sign in to comment.