The document contains C++ code that defines classes for different music types including Chamber, Orchestral, Pop, Jazz, Rock, and Electronic. It also defines enums for music type, tempo, improvisation, and volume. The code parses a JSON file containing music data and instantiates objects of the music classes. A test case is provided to test parsing a sample JSON file and validate the music type, tempo, and output of playing and printing attributes for each song.
6. cs.Play();
cout << cs.PrettyPrintClassAttributes() << endl << endl;
CHECK(cs.GetMusicType() == MusicMachine::MUSIC_TYPE::JAZZ);
CHECK(cs.IsTempoFast() == true);
}
/// Rock
vector<MusicMachine:: Rock> RockSongs = m.GetRockSongs();
for (auto& cs : RockSongs)
{
cs.Play();
cout << cs.PrettyPrintClassAttributes() << endl << endl;
CHECK(cs.GetMusicType() == MusicMachine::MUSIC_TYPE::ROCK);
CHECK(cs.IsTempoFast() == true);
}
/// Electronic
vector<MusicMachine::Electronic> ElectroinicSongs = m.GetElectronicSongs();
for(auto& cs : ElectroinicSongs)
{
cs.Play();
cout << cs.PrettyPrintClassAttributes() << endl << endl;
CHECK(cs.GetMusicType() == MusicMachine::MUSIC_TYPE::ELECTRONIC);
CHECK(cs.IsTempoFast() == true);
}
}
}
The output:
Notes
There should be 1 test case pass and 13 assertion passed and status would be SUCCESS All code
is to be developed in main.cpp. No additional header files will be accepted. Notice the output of
both the Play and PrettyPrintClassAttributes member functions. Note: PrettyPrintClassAttributes
does not print but returns a string to be printed. Also do not use algrothim header
Playing Chamber music... Tchaikovsky Russia,https://chamber.music.example.com,String
Quartet No. 1,G minor Violin Cello.Flute,Bassoona Playing Orchestral music...
Beethoven,Germany,htttps://orchestral.music,example.com,Symphony No.5,C minocilielin
Viola Timpani,Snare drum. Cymbals.Xylophene French hero, Piano, Hare Playing Pop music...
Justin Beiber,United States,https//pop.music.example.com,Ghost,02/12/2022,12 Playing Jazz
7. music... Miles Davis.United States,https://rock.music.example.com,School's Out,0,Loud Playing
Electronic music... Kraftwerk,Germany,https://electronic.music.example.com,Prologue,141