SlideShare a Scribd company logo
1 of 7
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 C++ Music Machine Enum Classes Test File

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.pdfannaistrvlr
 
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.pdfprajeetjain
 
maincpp include ltiostreamgt include ltstringgt.pdf
maincpp  include ltiostreamgt include ltstringgt.pdfmaincpp  include ltiostreamgt include ltstringgt.pdf
maincpp include ltiostreamgt include ltstringgt.pdfmukulsingh0025
 
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.pdfarihanthtextiles
 
API Development and Scala @ SoundCloud
API Development and Scala @ SoundCloudAPI Development and Scala @ SoundCloud
API Development and Scala @ SoundCloudBora 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.pdfAdrianEBJKingr
 

Similar to C++ Music Machine Enum Classes Test File (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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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-.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 
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.docxAustinIKkNorthy
 

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

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Recently uploaded (20)

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

C++ Music Machine Enum Classes Test File

  • 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