Question: 1 0 . 1 5 LAB: Instrument information ( derived classes ) Given main ( ) and the Instrument class, define a derived class, StringInstrument,
LAB: Instrument information derived classes
Given main and the Instrument class, define a derived class, StringInstrument, with methods to set and get private fields of the following types:
int to store the number of strings
int to store the number of frets
boolean to store whether the instrument is bowed
Ex If the input is:
Drums
Zildjian
Guitar
Gibson
false
the output is:
Instrument Information:
Name: Drums
Manufacturer: Zildjian
Year built:
Cost:
Instrument Information:
Name: Guitar
Manufacturer: Gibson
Year built:
Cost:
Number of strings:
Number of frets:
Is bowed: false
my code
public class StringInstrument extends Instrument
private int numOfStrings;
private int numOfFrets;
private boolean isBowed;
public void setNumOfStringsint num
numOfStrings num;
public void setNumOfFretsint num
numOfFrets num;
public void setIsBowedboolean bowed
isBowed bowed;
public int getNumOfStrings
return numOfStrings;
public int getNumOfFrets
return numOfFrets;
public boolean getIsBowed
return isBowed;
@Override
public void printInfo
super.printInfo;
System.out.printlnNumber of strings: numOfStrings;
System.out.printlnNumber of frets: numOfFrets;
System.out.printlnIs bowed: isBowed;
Current file: Stringlnstrument.java
When done developing your program, press the Submit for grading button below. This will
submit your program for autograding. wvalle: Drulls
Manufacturer: zildjian
Year built:
Cost:
Instrument Information:
Name: Guitar
Manufacturer: Gibson
Year built:
Cost:
Number of strings:
Number of frets:
Is bowed: falsew
Number of strings:
Number of frets:
Is bowed: false
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
