SlideShare a Scribd company logo
The Test File:
The code:
#include <iostream>
#include <vector>
#include <fstream>
#include "json.hpp"
using namespace std;
using json = nlohmann::json;
////
const std::string DATA_FILE_PATH = "TestData";
namespace MusicMachine {
// Music_Type enum class
enum class MUSIC_TYPE {
UNKNOWN,
CHAMBER,
ORCHESTRAL,
ROCK,
ELECTRONIC,
POP,
JAZZ,
BLUES
};
enum class TEMPO {
UNKNOWN,
SLOW,
FAST
};
enum class IMPROVISATION {
UNKNOWN,
SOLO,
COLLECTIVE
};
enum class VOLUME {
NA,
QUITE,
LOUD,
VERYLOUD
};
// Music class
class Music {
public:
Music(json& j, MUSIC_TYPE type, TEMPO tempo);
MUSIC_TYPE GetMusicType() const;
bool IsTempoFast() const;
void Play() const;
string PrettyPrintClassAttributes() const;
protected:
string ArtistName;
string Location;
MUSIC_TYPE MusicType;
string Orgin;
TEMPO Tempo;
};
// Classical class (inherits from Music)
class Classical : public Music {
public:
Classical(json& j, MUSIC_TYPE type, TEMPO tempo);
void Play() const;
string PrettyPrintClassAttributes() const;
private:
string Key;
string PieceName;
};
// NonClassical class (inherits from Music)
class NonClassical : public Music {
public:
NonClassical(json& j, MUSIC_TYPE type, TEMPO tempo);
void Play() const;
string PrettyPrintClassAttributes() const;
private:
string SongName;
};
// Chamber class (inherits from Classical)
class Chamber : public Classical {
public:
Chamber(json& j);
void Play() const;
string PrettyPrintClassAttributes() const;
private:
struct Instrument {
string One;
string Two;
string Three;
string Four;
};
Instrument Instruments;
};
// Orchestral class (inherits from Classical)
class Orchestral : public Classical {
public:
Orchestral(json& j);
void Play() const;
string PrettyPrintClassAttributes() const;
private:
vector<string> Instruments;
};
class Pop : public NonClassical {
public:
Pop(json& j);
void Play() const;
string PrettyPrintClassAttributes() const;
private:
std::string DateOFRanking;
int Top40Ranking;
};
class Jazz : public NonClassical {
public:
Jazz(json& j);
void Play() const;
string PrettyPrintClassAttributes() const;
private:
IMPROVISATION Improvisation;
};
class Rock : public NonClassical {
public:
Rock(json& j);
void Play() const;
std::string PrettyPrintClassAttributes() const;
private:
int Expletive;
bool GuitarsOnly;
VOLUME Volume;
std::string VolumeToString() const;
};
class Electronic : public NonClassical {
public:
Electronic(json& j);
void Play() const;
std::string PrettyPrintClassAttributes() const;
private:
int BeatsPerMinute;
};
class Machine {
public:
const vector<Chamber>& GetChamberSongs() const;
const vector<Electronic>& GetElectronicSongs() const;
const vector<Jazz>& GetJazzSongs() const;
const vector<Orchestral>& GetOrchestralSongs() const;
const vector<Pop>& GetPopSongs() const;
const vector<Rock>& GetRockSongs() const;
Machine(string filename);
size_t Parse() const;
private:
json jf;
vector<Chamber> SongsChamber;
vector<Electronic> SongsElectronic;
vector<Jazz> SongsJazz;
vector<Orchestral> SongsOrchestral;
vector<Rock> SongsRock;
vector<Pop> SongsPop;
};
}
//
////////////////////////////////////////////////////////////////////////////////////////////////
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
TEST_CASE("Testing my Music Machine")
{
SUBCASE("testing the parsing of file - JsonObject6a.json")
{
MusicMachine::Machine m(DATA_FILE_PATH + "JsonObject6a.json");
// Invoke the parsing process
CHECK(m.Parse() == 6);
/// Chamber
vector<MusicMachine::Chamber> ChamberSongs = m.GetChamberSongs();
for (auto& cs : ChamberSongs)
{
cs.Play();
cout << cs.PrettyPrintClassAttributes() << endl << endl;
CHECK(cs.GetMusicType() == MusicMachine::MUSIC_TYPE::CHAMBER);
CHECK(cs.IsTempoFast() == false);
}
/// Orchestral
vector<MusicMachine:: Orchestral> OrchestralSongs = m.GetOrchestralSongs();
for (auto& cs : OrchestralSongs)
{
cs.Play();
cout << cs.PrettyPrintClassAttributes() << endl << endl;
CHECK(cs.GetMusicType() == MusicMachine::MUSIC_TYPE::ORCHESTRAL);
CHECK(cs.IsTempoFast() == false);
}
/// Pop
vector<MusicMachine:: Pop> PopSongs = m.GetPopSongs();
for (auto& cs : PopSongs)
{
cs.Play();
cout << cs.PrettyPrintClassAttributes() << endl << endl;
CHECK(cs.GetMusicType() == MusicMachine::MUSIC_TYPE::POP);
CHECK(cs.IsTempoFast() == true);
}
/// Jazz
vector<MusicMachine:: Jazz> JazzSongs = m.GetJazzSongs();
for (auto& cs : JazzSongs)
{
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
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

More Related Content

Similar to The Test File- The code- #include -iostream- #include -vector- #includ.docx

The java program that display a menu of choices and p.pdf
   The java program that display a menu of choices  and p.pdf   The java program that display a menu of choices  and p.pdf
The java program that display a menu of choices and p.pdf
annaistrvlr
 
Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)fefe7270
 
Need help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdfNeed help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdf
prajeetjain
 
maincpp include ltiostreamgt include ltstringgt.pdf
maincpp  include ltiostreamgt include ltstringgt.pdfmaincpp  include ltiostreamgt include ltstringgt.pdf
maincpp include ltiostreamgt include ltstringgt.pdf
mukulsingh0025
 
I need help writing the methods for the song and playList class in J.pdf
I need help writing the methods for the song and playList class in J.pdfI need help writing the methods for the song and playList class in J.pdf
I need help writing the methods for the song and playList class in J.pdf
arihanthtextiles
 
API Development and Scala @ SoundCloud
API Development and Scala @ SoundCloudAPI Development and Scala @ SoundCloud
API Development and Scala @ SoundCloud
Bora Tunca
 
---BUS-- public class Bus { String busIdentifier- String driverName- d.pdf
---BUS-- public class Bus { String busIdentifier- String driverName- d.pdf---BUS-- public class Bus { String busIdentifier- String driverName- d.pdf
---BUS-- public class Bus { String busIdentifier- String driverName- d.pdf
AdrianEBJKingr
 

Similar to The Test File- The code- #include -iostream- #include -vector- #includ.docx (7)

The java program that display a menu of choices and p.pdf
   The java program that display a menu of choices  and p.pdf   The java program that display a menu of choices  and p.pdf
The java program that display a menu of choices and p.pdf
 
Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)
 
Need help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdfNeed help with this java project, as the methods are proving to be p.pdf
Need help with this java project, as the methods are proving to be p.pdf
 
maincpp include ltiostreamgt include ltstringgt.pdf
maincpp  include ltiostreamgt include ltstringgt.pdfmaincpp  include ltiostreamgt include ltstringgt.pdf
maincpp include ltiostreamgt include ltstringgt.pdf
 
I need help writing the methods for the song and playList class in J.pdf
I need help writing the methods for the song and playList class in J.pdfI need help writing the methods for the song and playList class in J.pdf
I need help writing the methods for the song and playList class in J.pdf
 
API Development and Scala @ SoundCloud
API Development and Scala @ SoundCloudAPI Development and Scala @ SoundCloud
API Development and Scala @ SoundCloud
 
---BUS-- public class Bus { String busIdentifier- String driverName- d.pdf
---BUS-- public class Bus { String busIdentifier- String driverName- d.pdf---BUS-- public class Bus { String busIdentifier- String driverName- d.pdf
---BUS-- public class Bus { String busIdentifier- String driverName- d.pdf
 

More from AustinIKkNorthy

Threats to auditor independence can come from various sources- Which o.docx
Threats to auditor independence can come from various sources- Which o.docxThreats to auditor independence can come from various sources- Which o.docx
Threats to auditor independence can come from various sources- Which o.docx
AustinIKkNorthy
 
Three conditions characterize difficult manageriat decisions concernin.docx
Three conditions characterize difficult manageriat decisions concernin.docxThree conditions characterize difficult manageriat decisions concernin.docx
Three conditions characterize difficult manageriat decisions concernin.docx
AustinIKkNorthy
 
this needs to be done in matlab Assignment 1 (5 points) Communicate wi.docx
this needs to be done in matlab Assignment 1 (5 points) Communicate wi.docxthis needs to be done in matlab Assignment 1 (5 points) Communicate wi.docx
this needs to be done in matlab Assignment 1 (5 points) Communicate wi.docx
AustinIKkNorthy
 
This is the -declare-txt-- In Congress- July 4- 1776 The unanimous De.docx
This is the -declare-txt--  In Congress- July 4- 1776 The unanimous De.docxThis is the -declare-txt--  In Congress- July 4- 1776 The unanimous De.docx
This is the -declare-txt-- In Congress- July 4- 1776 The unanimous De.docx
AustinIKkNorthy
 
This graphic (above) illustrates which process- Complete the following.docx
This graphic (above) illustrates which process- Complete the following.docxThis graphic (above) illustrates which process- Complete the following.docx
This graphic (above) illustrates which process- Complete the following.docx
AustinIKkNorthy
 
Think about a closed economy with two types of households- the wealthy.docx
Think about a closed economy with two types of households- the wealthy.docxThink about a closed economy with two types of households- the wealthy.docx
Think about a closed economy with two types of households- the wealthy.docx
AustinIKkNorthy
 
There is a problem completing the replication of linear chromosomes at.docx
There is a problem completing the replication of linear chromosomes at.docxThere is a problem completing the replication of linear chromosomes at.docx
There is a problem completing the replication of linear chromosomes at.docx
AustinIKkNorthy
 
There are two traits in Homo heidlebergensis that foreshadows the evol.docx
There are two traits in Homo heidlebergensis that foreshadows the evol.docxThere are two traits in Homo heidlebergensis that foreshadows the evol.docx
There are two traits in Homo heidlebergensis that foreshadows the evol.docx
AustinIKkNorthy
 
There is a 20- chance that Cinderella will lose her left shoe as she s.docx
There is a 20- chance that Cinderella will lose her left shoe as she s.docxThere is a 20- chance that Cinderella will lose her left shoe as she s.docx
There is a 20- chance that Cinderella will lose her left shoe as she s.docx
AustinIKkNorthy
 
There are many advantages of ICT that benefit the marketing function o.docx
There are many advantages of ICT that benefit the marketing function o.docxThere are many advantages of ICT that benefit the marketing function o.docx
There are many advantages of ICT that benefit the marketing function o.docx
AustinIKkNorthy
 
There are three horizontal sedimentary layers stacked on top of each o.docx
There are three horizontal sedimentary layers stacked on top of each o.docxThere are three horizontal sedimentary layers stacked on top of each o.docx
There are three horizontal sedimentary layers stacked on top of each o.docx
AustinIKkNorthy
 
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docxThere are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
AustinIKkNorthy
 
There are ongoing concerns about how accurate the CPI is in measuring.docx
There are ongoing concerns about how accurate the CPI is in measuring.docxThere are ongoing concerns about how accurate the CPI is in measuring.docx
There are ongoing concerns about how accurate the CPI is in measuring.docx
AustinIKkNorthy
 
There are 12 cualfed candidates- and olficers can also serve on the co.docx
There are 12 cualfed candidates- and olficers can also serve on the co.docxThere are 12 cualfed candidates- and olficers can also serve on the co.docx
There are 12 cualfed candidates- and olficers can also serve on the co.docx
AustinIKkNorthy
 
The Wall had protected Westeros from the dangers of the wildlings for.docx
The Wall had protected Westeros from the dangers of the wildlings for.docxThe Wall had protected Westeros from the dangers of the wildlings for.docx
The Wall had protected Westeros from the dangers of the wildlings for.docx
AustinIKkNorthy
 
The U-S- remains commited to a policy of funding health care through a.docx
The U-S- remains commited to a policy of funding health care through a.docxThe U-S- remains commited to a policy of funding health care through a.docx
The U-S- remains commited to a policy of funding health care through a.docx
AustinIKkNorthy
 
The two major cavities are the dorsal cavity and the ventral cavity 17.docx
The two major cavities are the dorsal cavity and the ventral cavity 17.docxThe two major cavities are the dorsal cavity and the ventral cavity 17.docx
The two major cavities are the dorsal cavity and the ventral cavity 17.docx
AustinIKkNorthy
 
the total population- 83-190-556 Femsie Regulaben Apte 35-30 Ferisie.docx
the total population- 83-190-556  Femsie Regulaben Apte 35-30 Ferisie.docxthe total population- 83-190-556  Femsie Regulaben Apte 35-30 Ferisie.docx
the total population- 83-190-556 Femsie Regulaben Apte 35-30 Ferisie.docx
AustinIKkNorthy
 
The theoretical level serving as the interface between phonology and s.docx
The theoretical level serving as the interface between phonology and s.docxThe theoretical level serving as the interface between phonology and s.docx
The theoretical level serving as the interface between phonology and s.docx
AustinIKkNorthy
 
The term (1- ) refers to- the level of consistency the level of co.docx
The term (1- ) refers to-   the level of consistency   the level of co.docxThe term (1- ) refers to-   the level of consistency   the level of co.docx
The term (1- ) refers to- the level of consistency the level of co.docx
AustinIKkNorthy
 

More from AustinIKkNorthy (20)

Threats to auditor independence can come from various sources- Which o.docx
Threats to auditor independence can come from various sources- Which o.docxThreats to auditor independence can come from various sources- Which o.docx
Threats to auditor independence can come from various sources- Which o.docx
 
Three conditions characterize difficult manageriat decisions concernin.docx
Three conditions characterize difficult manageriat decisions concernin.docxThree conditions characterize difficult manageriat decisions concernin.docx
Three conditions characterize difficult manageriat decisions concernin.docx
 
this needs to be done in matlab Assignment 1 (5 points) Communicate wi.docx
this needs to be done in matlab Assignment 1 (5 points) Communicate wi.docxthis needs to be done in matlab Assignment 1 (5 points) Communicate wi.docx
this needs to be done in matlab Assignment 1 (5 points) Communicate wi.docx
 
This is the -declare-txt-- In Congress- July 4- 1776 The unanimous De.docx
This is the -declare-txt--  In Congress- July 4- 1776 The unanimous De.docxThis is the -declare-txt--  In Congress- July 4- 1776 The unanimous De.docx
This is the -declare-txt-- In Congress- July 4- 1776 The unanimous De.docx
 
This graphic (above) illustrates which process- Complete the following.docx
This graphic (above) illustrates which process- Complete the following.docxThis graphic (above) illustrates which process- Complete the following.docx
This graphic (above) illustrates which process- Complete the following.docx
 
Think about a closed economy with two types of households- the wealthy.docx
Think about a closed economy with two types of households- the wealthy.docxThink about a closed economy with two types of households- the wealthy.docx
Think about a closed economy with two types of households- the wealthy.docx
 
There is a problem completing the replication of linear chromosomes at.docx
There is a problem completing the replication of linear chromosomes at.docxThere is a problem completing the replication of linear chromosomes at.docx
There is a problem completing the replication of linear chromosomes at.docx
 
There are two traits in Homo heidlebergensis that foreshadows the evol.docx
There are two traits in Homo heidlebergensis that foreshadows the evol.docxThere are two traits in Homo heidlebergensis that foreshadows the evol.docx
There are two traits in Homo heidlebergensis that foreshadows the evol.docx
 
There is a 20- chance that Cinderella will lose her left shoe as she s.docx
There is a 20- chance that Cinderella will lose her left shoe as she s.docxThere is a 20- chance that Cinderella will lose her left shoe as she s.docx
There is a 20- chance that Cinderella will lose her left shoe as she s.docx
 
There are many advantages of ICT that benefit the marketing function o.docx
There are many advantages of ICT that benefit the marketing function o.docxThere are many advantages of ICT that benefit the marketing function o.docx
There are many advantages of ICT that benefit the marketing function o.docx
 
There are three horizontal sedimentary layers stacked on top of each o.docx
There are three horizontal sedimentary layers stacked on top of each o.docxThere are three horizontal sedimentary layers stacked on top of each o.docx
There are three horizontal sedimentary layers stacked on top of each o.docx
 
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docxThere are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
 
There are ongoing concerns about how accurate the CPI is in measuring.docx
There are ongoing concerns about how accurate the CPI is in measuring.docxThere are ongoing concerns about how accurate the CPI is in measuring.docx
There are ongoing concerns about how accurate the CPI is in measuring.docx
 
There are 12 cualfed candidates- and olficers can also serve on the co.docx
There are 12 cualfed candidates- and olficers can also serve on the co.docxThere are 12 cualfed candidates- and olficers can also serve on the co.docx
There are 12 cualfed candidates- and olficers can also serve on the co.docx
 
The Wall had protected Westeros from the dangers of the wildlings for.docx
The Wall had protected Westeros from the dangers of the wildlings for.docxThe Wall had protected Westeros from the dangers of the wildlings for.docx
The Wall had protected Westeros from the dangers of the wildlings for.docx
 
The U-S- remains commited to a policy of funding health care through a.docx
The U-S- remains commited to a policy of funding health care through a.docxThe U-S- remains commited to a policy of funding health care through a.docx
The U-S- remains commited to a policy of funding health care through a.docx
 
The two major cavities are the dorsal cavity and the ventral cavity 17.docx
The two major cavities are the dorsal cavity and the ventral cavity 17.docxThe two major cavities are the dorsal cavity and the ventral cavity 17.docx
The two major cavities are the dorsal cavity and the ventral cavity 17.docx
 
the total population- 83-190-556 Femsie Regulaben Apte 35-30 Ferisie.docx
the total population- 83-190-556  Femsie Regulaben Apte 35-30 Ferisie.docxthe total population- 83-190-556  Femsie Regulaben Apte 35-30 Ferisie.docx
the total population- 83-190-556 Femsie Regulaben Apte 35-30 Ferisie.docx
 
The theoretical level serving as the interface between phonology and s.docx
The theoretical level serving as the interface between phonology and s.docxThe theoretical level serving as the interface between phonology and s.docx
The theoretical level serving as the interface between phonology and s.docx
 
The term (1- ) refers to- the level of consistency the level of co.docx
The term (1- ) refers to-   the level of consistency   the level of co.docxThe term (1- ) refers to-   the level of consistency   the level of co.docx
The term (1- ) refers to- the level of consistency the level of co.docx
 

Recently uploaded

Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 

Recently uploaded (20)

Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 

The Test File- The code- #include -iostream- #include -vector- #includ.docx

  • 1. The Test File: The code: #include <iostream> #include <vector> #include <fstream> #include "json.hpp" using namespace std; using json = nlohmann::json; //// const std::string DATA_FILE_PATH = "TestData"; namespace MusicMachine { // Music_Type enum class enum class MUSIC_TYPE { UNKNOWN, CHAMBER, ORCHESTRAL, ROCK, ELECTRONIC, POP, JAZZ, BLUES }; enum class TEMPO { UNKNOWN, SLOW, FAST }; enum class IMPROVISATION { UNKNOWN, SOLO, COLLECTIVE }; enum class VOLUME { NA, QUITE, LOUD, VERYLOUD };
  • 2. // Music class class Music { public: Music(json& j, MUSIC_TYPE type, TEMPO tempo); MUSIC_TYPE GetMusicType() const; bool IsTempoFast() const; void Play() const; string PrettyPrintClassAttributes() const; protected: string ArtistName; string Location; MUSIC_TYPE MusicType; string Orgin; TEMPO Tempo; }; // Classical class (inherits from Music) class Classical : public Music { public: Classical(json& j, MUSIC_TYPE type, TEMPO tempo); void Play() const; string PrettyPrintClassAttributes() const; private: string Key; string PieceName; }; // NonClassical class (inherits from Music) class NonClassical : public Music { public: NonClassical(json& j, MUSIC_TYPE type, TEMPO tempo); void Play() const; string PrettyPrintClassAttributes() const; private: string SongName; }; // Chamber class (inherits from Classical) class Chamber : public Classical { public: Chamber(json& j); void Play() const; string PrettyPrintClassAttributes() const; private: struct Instrument { string One;
  • 3. string Two; string Three; string Four; }; Instrument Instruments; }; // Orchestral class (inherits from Classical) class Orchestral : public Classical { public: Orchestral(json& j); void Play() const; string PrettyPrintClassAttributes() const; private: vector<string> Instruments; }; class Pop : public NonClassical { public: Pop(json& j); void Play() const; string PrettyPrintClassAttributes() const; private: std::string DateOFRanking; int Top40Ranking; }; class Jazz : public NonClassical { public: Jazz(json& j); void Play() const; string PrettyPrintClassAttributes() const; private: IMPROVISATION Improvisation; }; class Rock : public NonClassical { public: Rock(json& j); void Play() const; std::string PrettyPrintClassAttributes() const; private: int Expletive; bool GuitarsOnly; VOLUME Volume;
  • 4. std::string VolumeToString() const; }; class Electronic : public NonClassical { public: Electronic(json& j); void Play() const; std::string PrettyPrintClassAttributes() const; private: int BeatsPerMinute; }; class Machine { public: const vector<Chamber>& GetChamberSongs() const; const vector<Electronic>& GetElectronicSongs() const; const vector<Jazz>& GetJazzSongs() const; const vector<Orchestral>& GetOrchestralSongs() const; const vector<Pop>& GetPopSongs() const; const vector<Rock>& GetRockSongs() const; Machine(string filename); size_t Parse() const; private: json jf; vector<Chamber> SongsChamber; vector<Electronic> SongsElectronic; vector<Jazz> SongsJazz; vector<Orchestral> SongsOrchestral; vector<Rock> SongsRock; vector<Pop> SongsPop; }; } // //////////////////////////////////////////////////////////////////////////////////////////////// #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include "doctest.h" TEST_CASE("Testing my Music Machine") { SUBCASE("testing the parsing of file - JsonObject6a.json") {
  • 5. MusicMachine::Machine m(DATA_FILE_PATH + "JsonObject6a.json"); // Invoke the parsing process CHECK(m.Parse() == 6); /// Chamber vector<MusicMachine::Chamber> ChamberSongs = m.GetChamberSongs(); for (auto& cs : ChamberSongs) { cs.Play(); cout << cs.PrettyPrintClassAttributes() << endl << endl; CHECK(cs.GetMusicType() == MusicMachine::MUSIC_TYPE::CHAMBER); CHECK(cs.IsTempoFast() == false); } /// Orchestral vector<MusicMachine:: Orchestral> OrchestralSongs = m.GetOrchestralSongs(); for (auto& cs : OrchestralSongs) { cs.Play(); cout << cs.PrettyPrintClassAttributes() << endl << endl; CHECK(cs.GetMusicType() == MusicMachine::MUSIC_TYPE::ORCHESTRAL); CHECK(cs.IsTempoFast() == false); } /// Pop vector<MusicMachine:: Pop> PopSongs = m.GetPopSongs(); for (auto& cs : PopSongs) { cs.Play(); cout << cs.PrettyPrintClassAttributes() << endl << endl; CHECK(cs.GetMusicType() == MusicMachine::MUSIC_TYPE::POP); CHECK(cs.IsTempoFast() == true); } /// Jazz vector<MusicMachine:: Jazz> JazzSongs = m.GetJazzSongs(); for (auto& cs : JazzSongs) {
  • 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