Question: My Assingment is to create this program: Create a class called Musicians to contain three functions string ( ), wind ( ) and perc (

My Assingment is to create this program:

Create a class called Musicians to contain three functions string ( ), wind ( ) and perc ( ).

Each of these functions should initialize a string array to contain the following instruments: - veena, guitar, sitar, sarod and mandolin under string ( ) - flute, clarinet saxophone, nadhaswaram and piccolo under wind ( ) - tabla, mridangam, bangos, drums and tambour under perc ( )

It should also display the contents of the arrays that are initialized.

Create a derived class called TypeIns to contain a function called get ( ) and show ( ). The get ( ) function must display a means as follows:

Type of instruments to be displayed a. String instruments b. ind instruments c. Percussion instruments

The show ( ) function should display the relevant detail according to our choice. The base class variables must be accessible only to its derived classes.

So Far I have gotten this far and have come up an incomplete program if I could get some help solving this problem that would be great:

#include

#include

using namespace std;

class Instrument

{

protected:

char info[15][15];

public:

void wind()

{

strcpy(info[0], "Flute");

strcpy(info[1], "Clarinet");

strcpy(info[2], "Sexophone");

strcpy(info[3], "Nadhaswaram");

strcpy(info[4], "Picoolo");

}

void string()

{

strcpy(info[0], "Veena");

strcpy(info[1], "Guitar");

strcpy(info[2], "Sitar");

strcpy(info[3], "Sarod");

strcpy(info[4], "Mandolin");

}

void perc(void)

{

strcpy(info[0], "Tabla");

strcpy(info[1], "Mridangam");

strcpy(info[2], "Bangos");

strcpy(info[3], "Drums");

strcpy(info[4], "Tambour");

}

void build()

{

for(int i=0; i<5; i++)

{

cout << info[i] ;

cout << " " << endl;

}

}

};

class typIns : public Instrument

{

public:

void get()

{

cout<<"A. String Instrument"<

cout<<"B. Ind Instrument"<

cout<<"C. Percussion Instrument"<

}

void build(char build)

{

if(build == 'A' || build == 'a'){

string();

Instrument::build();

}

else if( build == 'B' || build == 'b'){

wind();

Instrument::build();

}

else{

perc();

Instrument::build();

}

}

};

int main()

{

char again;

do {

int a;

typIns b;

b.get();

cout << " Enter the type of Instrument(1, 2, or 3): " << endl;

cin >> a;

b.build(a);

cout << " Would you like to look up other instruments(Y or N): ";

cin >> again;

}

while (again =='y' || again =='Y');

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!