Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions