Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Could you answer and explain the following question. Given main() and the Instrument class, define a derived class, String Instrument, for string instruments. Ex. If

Could you answer and explain the following question.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
Given main() and the Instrument class, define a derived class, String Instrument, for string instruments. Ex. If the input is: Drums Zildjian 2015 2500 Guitar Gibson 2002 1200 6 19 the output is: Instrument Information: Name : Drums Manufacturer: Zildjian Year built: 2015 Cost : 2500 Instrument Information: Name: Guitar Manufacturer: Gibson Year built: 2002 Cost: 1200 Number of strings: 6 Number of frets: 19File is marked as read only Current file: main.cpp 1 #include "StringInstrument.h" int main( ) { Instrument my Instrument; StringInstrument myStringInstrument; string instrumentName, manufacturerName, stringInstrumentName, stringManufacturer, yearBuilt, 8 cost, stringYearBuilt, stringCost, numStrings, numFrets; 9 10 getline(cin, instrumentName); 11 getline (cin, manufacturerName) ; 12 getline(cin, yearBuilt); 13 getline(cin, cost); 14 15 getline(cin, stringInstrumentName) ; 16 getline(cin, stringManufacturer); 17 getline(cin, stringYearBuilt); 18 getline(cin, stringCost); 19 getline(cin, numStrings); 20 getline(cin, numFrets); 21 22 my Instrument . SetName (instrumentName ); 23 my Instrument . SetManufacturer (manufacturerName) ; 24 my Instrument . SetYearBuilt (yearBuilt); 25 my Instrument . SetCost (cost); 26 my Instrument . PrintInfo ( ) ; 27 28 myStringInstrument . SetName (stringInstrumentName) ; 29 myStringInstrument . SetManufacturer(stringManufacturer) ; 30 myString Instrument . SetYearBuilt(stringYearBuilt); 31 myStringInstrument . SetCost(stringCost) ; 32 myString Instrument . SetNumOfStrings(numStrings); 33 myStringInstrument . SetNumOfFrets (numFrets ) ; 34 myStringInstrument . PrintInfo(); 35 36 cout #include using namespace std; 9 class Instrument { 10 protected: 11 string instrumentName; 12 string instrumentManufacturer; 13 string yearBuilt; 14 string cost; 15 16 public: 17 void SetName (string userName) ; 18 19 string GetName ( ) ; 20 21 void SetManufacturer (string userManufacturer); 22 23 string GetManufacturer(); 24 25 void SetYearBuilt(string userYearBuilt); 26 27 string GetYearBuilt(); 28 29 void SetCost(string userCost); 30 31 string GetCost(); 32 33 void PrintInfo(); 34 } 35 36 #endif\fFile is marked as read only Current file: Instrument.cpp #include "Instrument.h" void Instrument : : SetName (string userName) { instrumentName = userName; string Instrument : :GetName ( ) { return instrumentName; 9 } 10 11 void Instrument: : SetManufacturer (string userManufacturer) { 12 instrumentManufacturer = userManufacturer; 13 } 14 15 string Instrument: : GetManufacturer() { 16 return instrumentManufacturer; 17 } 18 19 void Instrument: : SetYearBuilt(string userYearBuilt) { 20 yearBuilt = userYearBuilt; 21 } 22 23 string Instrument: :GetYearBuilt() { 24 return yearBuilt; 25 } 26 27 void Instrument: :SetCost (string userCost) { 28 cost = userCost; 29 } 30 31 string Instrument: :GetCost() { 32 return cost; 33 } 34 35 void Instrument: : PrintInfo( ) { 36 cout

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

Unity From Zero To Proficiency Beginner A Step By Step Guide To Coding Your First Game

Authors: Patrick Felicia

1st Edition

1091872023, 978-1091872028

More Books

Students also viewed these Programming questions