-
Notifications
You must be signed in to change notification settings - Fork 0
/
Interface.cpp
45 lines (41 loc) · 1.15 KB
/
Interface.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
#include"Interface.h"
int Interface::chooseQuanity()
{
system("clear");
int n;
cout<<"Write amount of variables: ";
cin>>n;
assert(n);
return n;
}
void Interface::run()
{
SortingMachine machine(chooseQuanity());
machine.randomData();
runSortingMachine(machine);
showResults(machine);
}
void Interface::runSortingMachine(SortingMachine& machine)
{
string x="QuickSort";
machine.addAlgorithm(x, &Algorithms::QuickSortStart);
x="InsertionSort";
machine.addAlgorithm(x, &Algorithms::InsertionSort);
x="BubbleSort";
machine.addAlgorithm(x, &Algorithms::BubbleSort);
x="SelectionSort";
machine.addAlgorithm(x, &Algorithms::SelectionSort);
machine.runAll();
}
void Interface::showResults(SortingMachine& machine)
{
system("clear");
machine.sortResults();
double TIME;
for (vector<SortTest*>::const_iterator i = machine.first(); i != machine.last(); i++)
{
TIME=1.0*(*i)->getTime()/CLOCKS_PER_SEC;
cout << setw(15) << left << (*i)->getName() << setw(10) << setprecision(3) << fixed << right << TIME << "s" << endl;
}
getchar();
}