-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenu.cpp
68 lines (64 loc) · 2.63 KB
/
Menu.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
62
63
64
65
66
67
68
#include "Menu.h"
#include <chrono>
Menu::Menu() = default;
void Menu::start(vector<Van> vans, vector<Parcel> parcels) {
unsigned short answer;
bool error = true;
do {
cout <<
"-----------------------------" << endl <<
"| Deliveries |" << endl <<
"|Number of workers: 1 |" << endl <<
"|Company's profit: 2 |" << endl <<
"|Express deliveries: 3 |" << endl <<
"|Exit: 0 |" << endl <<
"-----------------------------" << endl;
cin >> answer;
if (cin.eof()) {
exit(0);
}
if (!cin.good()) {
cout << "Sadly that's not an option. Please choose another one." << std::endl;
cin.clear();
cin.ignore(numeric_limits<int>::max(), '\n');
continue;
}
switch (answer) {
case 1: {
chrono::high_resolution_clock::time_point start1, end1;
Scenario1 scenario1 = Scenario1(vans, parcels);
start1 = chrono::high_resolution_clock::now();
scenario1.minOfVans();
end1 = chrono::high_resolution_clock::now();
cout << '\n' << "total of " << chrono::duration_cast<chrono::microseconds>(end1-start1).count() << " elapsed microseconds";
error = false;
break;
}
case 2: {
chrono::high_resolution_clock::time_point start2, end2;
Scenario2 s2 = Scenario2(vans, parcels);
start2 = chrono::high_resolution_clock::now();
s2.start();
s2.show();
end2 = chrono::high_resolution_clock::now();
cout << '\n' << "total of " << chrono::duration_cast<chrono::microseconds>(end2-start2).count() << " elapsed microseconds";
error = false;
break;
}
case 3: {
chrono::high_resolution_clock::time_point start3, end3;
Scenario3 scenario3;
start3 = chrono::high_resolution_clock::now();
scenario3.getMeanTime();
end3 = chrono::high_resolution_clock::now();
cout << '\n' << "total of " << chrono::duration_cast<std::chrono::microseconds>(end3-start3).count() << " elapsed microseconds";
error = false;
break;
}
case 0:
exit(0);
default:
cout << "Sadly that's not an option. Please choose another one." << endl;
}
} while (error);
}