File tree Expand file tree Collapse file tree 1 file changed +14
-11
lines changed
Expand file tree Collapse file tree 1 file changed +14
-11
lines changed Original file line number Diff line number Diff line change 1616
1717using namespace std ;
1818
19- const string ERROR_COLOR = " \033 [31m" ;
20- const string NORMAL_COLOR = " \033 [0m" ;
19+ const string COLOR_ERROR = " \033 [31m" ;
20+ const string COLOR_RESET = " \033 [0m" ;
2121
22- const int ZERO = 48 ;
23- const int NINE = 57 ;
24- const int MAX_DIGIT = 10 ;
25- const int MINUS = 45 ;
22+ const int ASCII_ZERO = 48 ;
23+ const int ASCII_NINE = 57 ;
24+ const int ASCII_MINUS = 45 ;
25+ const int MAX_DIGITS = 10 ;
2626
2727int insertNumber (string position);
2828bool checkStringIsNumber (string in);
@@ -48,7 +48,7 @@ int insertNumber(string position){
4848 string insert;
4949 bool isCorrect = true ;
5050 do {
51- if (!isCorrect) cout << ERROR_COLOR +(" [Insert a valid input] " )+NORMAL_COLOR ;
51+ if (!isCorrect) cout << COLOR_ERROR +(" [Insert a valid input] " )+COLOR_RESET ;
5252 cout << " Insert " << position <<" number: " ;
5353 getline (cin, insert);
5454
@@ -59,12 +59,15 @@ int insertNumber(string position){
5959}
6060
6161bool checkStringIsNumber (string in){
62- if (in.empty ()) return false ;
63- if (in.size () > MAX_DIGIT) return false ;
62+ if (in.empty ())
63+ return false ;
64+ if (in.size () > MAX_DIGITS)
65+ return false ;
6466
6567 for (int i = 0 ; i < in.size (); i++)
66- if ((in.at (i) < ZERO || in.at (i) > NINE) && in.at (i) != MINUS)
67- return false ;
68+ if ((in.at (i) < ASCII_ZERO || in.at (i) > ASCII_NINE))
69+ if (in.at (i) != ASCII_MINUS)
70+ return false ;
6871
6972 return true ;
7073}
You can’t perform that action at this time.
0 commit comments