-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathw7_p2.cpp
More file actions
83 lines (69 loc) · 2.32 KB
/
w7_p2.cpp
File metadata and controls
83 lines (69 loc) · 2.32 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
#include <iostream>
#include <iomanip>
#include <string>
#include <list>
#include "CovidCollection.h"
#include "CovidCollection.h"
void printbar(std::ostream& out = std::cout)
{
out << std::setw(89) << std::setfill('-') << '\n' << std::setfill(' ');
}
void printHeader(const char* title, std::ostream& out = std::cout)
{
printbar(out);
out << "| " << std::left << std::setw(85) << title << std::right << "|\n";
printbar(out);
}
int main(int argc, char** argv)
{
std::cout << "Command Line:\n";
std::cout << "--------------------------\n";
for (int i = 0; i < argc; i++)
std::cout << std::setw(3) << i + 1 << ": " << argv[i] << '\n';
std::cout << "--------------------------\n\n";
sdds::CovidCollection theCollection(argv[1]);
printHeader("The original collection");
theCollection.display(std::cout);
printbar();
printHeader("The collection sorted by country");
theCollection.sort("country");
theCollection.display(std::cout);
printbar();
printHeader("The collection sorted by variants");
theCollection.sort("variant");
theCollection.display(std::cout);
printbar();
printHeader("The collection sorted by total cases");
theCollection.sort("cases");
theCollection.display(std::cout);
printbar();
printHeader("The collection sorted by deaths");
theCollection.sort("deaths");
theCollection.display(std::cout);
printbar();
printHeader("The collection with fixed covid variants names");
theCollection.cleanList();
theCollection.display(std::cout);
printbar();
{
// looking for "Omicron" in the collection
if (theCollection.inCollection("Omicron"))
std::cout << "There are covid variants of \"Omicron\" in collection.\n";
else
std::cout << "There are no covid variants \"Omicron\" in collection.\n";
}
{
// look for Gamma variants; the death for Gamma variants were underreported by 50 deaths
if (theCollection.inCollection("Gamma"))
{
printHeader("Covid Variant of \"Gamma\"");
auto gamma = theCollection.getListForVariant("Gamma");
for (auto& covid : gamma)
{
std::cout << covid << "\n";
covid.m_deaths += 50;
}
printbar();
}
}
}