-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommand_Line_UI.cpp
More file actions
87 lines (74 loc) · 2.79 KB
/
Command_Line_UI.cpp
File metadata and controls
87 lines (74 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
std::pair<int,char> mainScreen();
//TODO: Implement or delete this
void clearScreen();
void sortingSplashScreen();
char closingScreen();
std::pair<int,char> mainScreen(){
std::pair<int,char> choices;
int dataSelection = 0; // User_id, ..., 5 total
char sortingFormat = 'c'; //ascending(A) or descending(B)
bool invalid = false;
std::cout<<"WELCOME, PLEASE SELECT DATA TO BE SORTED"<<std::endl;
std::cout<<"----------------------------------------"<<std::endl;
std::cout<<std::endl<<"1) User ID\n2) Item ID\n3) Movie Title\n4) Rating\n5) Time Stamp\nTo quit \"-1\""<<std::endl;
std::cout<<std::endl<<"Choice (Type an integer 1-5, or -1): ";
std::cin>> dataSelection;
if(dataSelection < -1 || dataSelection > 5 || dataSelection == 0){
invalid = true;
while(invalid){
std::cout<<"ERROR TRY AGAIN: Choice (Type an integer 1-5, or -1): ";
std::cin>> dataSelection;
if(dataSelection == -1 || (dataSelection > 0 && dataSelection <= 5)){
invalid = false;
}
}
}
clearScreen();
if(dataSelection != -1){
std::cout<<"DATA SELECTED, PLEASE SELECT SORTING FORMAT"<<std::endl;
std::cout<<"-------------------------------------------"<<std::endl;
std::cout<<"A) Ascending (Max)\nB) Descending (Min)"<<std::endl;
std::cout<<std::endl<<"Choice (Type a char: A a B b): ";
std::cin>>sortingFormat;
if(sortingFormat == 'A' || sortingFormat == 'a' || sortingFormat == 'B' || sortingFormat == 'b'){
invalid = false;
}else{
invalid = true;
while(invalid){
std::cout<<"ERROR TRY AGAIN: Choice (Type a char: A a B b): ";
std::cin>>sortingFormat;
if(sortingFormat == 'A' || sortingFormat == 'a' || sortingFormat == 'B' || sortingFormat == 'b'){
invalid = false;
}
}
}
}
choices.first = dataSelection;
choices.second = sortingFormat;
return choices;
}
void clearScreen(){
std::cout << "\033[2J\033[1;1H";
}
void sortingSplashScreen(){
std::cout<<"Please wait currently sorting";
}
char closingScreen(){
char choice = 'c';
bool invalid = false;
std::cout<<"Would you like to sort again? (y or Y for Yes, n or N for No): ";
std::cin>>choice;
if(choice == 'Y' || choice == 'y' || choice == 'N' || choice == 'n'){
invalid = false;
} else{
invalid = true;
while(invalid){
std::cout<<"ERROR TRY AGAIN: Would you like to sort again? (y or Y for Yes, n or N for No): ";
std::cin>>choice;
if(choice == 'Y' || choice == 'y' || choice == 'N' || choice == 'n'){
invalid = false;
}
}
}
return choice;
}