Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 0b9a52d1 authored by MaxwellLi-Umich's avatar MaxwellLi-Umich
Browse files

done

parent ccff25be
......@@ -21,7 +21,7 @@
# TODO (begin) #
#######################
# Change 'youruniqname' to match your UM uniqname (no quote marks).
UNIQNAME = youruniqname
UNIQNAME = maxwelli
# Change the right hand side of the identifier to match the project identifier
# given in the project or lab specification.
......
......@@ -161,34 +161,39 @@ void MusicLibrary::get_options(int argc, char** argv) {
/*
TODO: Add the remaining elements into the longOpts array.
DONE: Add the remaining elements into the longOpts array.
*/
// use getopt to find command line options
struct option longOpts[] = {{ "print", required_argument, nullptr, 'p' },
{ "name", no_argument, nullptr, 'n' },
{ "artist", no_argument, nullptr, 'a' },
{ "listens", no_argument, nullptr, 'l' },
{ "help", no_argument, nullptr, 'h' },
{ nullptr, 0, nullptr, '\0' }};
/*
TODO: Add the remaining chars to the option string in
DONE: Add the remaining chars to the option string in
the while loop conditional (currently contains "p:h").
Options with required_argument (print) need a colon after the
char, options with no_argument do not (help).
*/
while ((option = getopt_long(argc, argv, "p:h", longOpts, &option_index)) != -1) {
while ((option = getopt_long(argc, argv, "p:nalh", longOpts, &option_index)) != -1) {
switch (option) {
case 'p':
num_print = std::atoi(optarg);
break;
/*
TODO: Add the remaining cases and decide what to do when they occur.
*/
case 'n':
policy = 'n';
break;
case 'a':
policy = 'a';
break;
case 'l':
policy = 'l';
break;
case 'h':
std::cout << "This program reads a CSV file that contains song names,\n"
<< "the artist who wrote them, and the number of plays each song\n"
......@@ -304,10 +309,15 @@ void MusicLibrary::run() {
if (policy == 'n') {
std::sort(music.begin(), music.end(), Song::NameSort());
}
if (policy == 'a') {
std::sort(music.begin(), music.end(), Song::ArtistSort());
}
if (policy == 'l') {
std::sort(music.begin(), music.end(), Song::ListensSort());
}
/*
TODO: Add the remaining sorting cases (sorting by artist and listens).
DONE: Add the remaining sorting cases (sorting by artist and listens).
*/
......@@ -320,3 +330,66 @@ void MusicLibrary::run() {
......@@ -43,4 +43,4 @@ struct Song {
std::ostream& operator<<(std::ostream& out, const Song& song) {
return out << song.name << " by " << song.artist << " has "
<< std::to_string(song.plays) << " plays.";
}
\ No newline at end of file
}
......@@ -21,11 +21,11 @@
# TODO (begin) #
#######################
# Change 'youruniqname' to match your UM uniqname (no quote marks).
UNIQNAME = youruniqname
UNIQNAME = maxwelli
# Change the right hand side of the identifier to match the project identifier
# given in the project or lab specification.
IDENTIFIER = EEC50281EEC50281EEC50281EEC50281EEC50281
IDENTIFIER = CD7E23DEB13C1B8840F765F9016C084FD5D3F130
EXECUTABLE = profiling
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment