-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
61 lines (49 loc) · 1.18 KB
/
Main.cpp
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
#include "ListController.h"
int main()
{
ListController currentSession;
int menuChoice = 1;
currentSession.displayWelcome();
while (menuChoice != 0)
{
currentSession.displayMenu();
cin >> menuChoice;
while (cin.fail() || menuChoice < 0 || menuChoice > 4 || cin.peek() == '.')
{
cout << endl << "That's not a valid choice, please enter 1-4, or 0 to exit: " << endl;
cin.clear();
cin.ignore(INT_MAX, '\n');
cin >> menuChoice;
}
switch (menuChoice)
{
case 1:
// Add a number to the list in order
currentSession.add();
break;
case 2:
// Delete the given number from the list
currentSession.remove();
break;
case 3:
// Display list in ascending order
currentSession.displayAscending();
break;
case 4:
// Display list in descending order
currentSession.displayDescending();
break;
case 0:
// If the user wants to exit, display tdon't display an error message and exit.
break;
default:
// If not an expected entry, get a new choice number
cout << "That's not a valid choice, please enter 1-4, or 0 to exit: " << endl;
cin.clear();
cin.ignore(INT_MAX, '\n');
cin >> menuChoice;
break;
}
}
return 0;
}