Answer:
Step-by-step explanation:
The following code is written in Java and creates the classes, variables, and methods as requested. The String objects created are not being passed a family string argument in this question, therefore I created two constructors for the String class where the second constructor has a default value of String for family.
package sample;
class InstrumentTester {
public static void main(String[] args) {
/*** Don't Change This Tester Class!** When you are finished, this should run without error.*/
Wind tuba = new Wind("Tuba", "Brass", false);
Wind clarinet = new Wind("Clarinet", "Woodwind", true);
Strings violin = new Strings("Violin", true);
Strings harp = new Strings("Harp", false);
System.out.println(tuba);
System.out.println(clarinet);
System.out.println(violin);
System.out.println(harp);
}
}
class Wind extends Instrument {
boolean usesReef;
public Wind(String name, String family, boolean usesReef) {
this.setName(name);
this.setFamily(family);
this.usesReef = usesReef;
}
public boolean isUsesReef() {
return usesReef;
}
public void setUsesReef(boolean usesReef) {
this.usesReef = usesReef;
}
}
class Strings extends Instrument{
boolean usesBow;
public Strings (String name, String family, boolean usesBow) {
this.setName(name);
this.setFamily(family);
this.usesBow = usesBow;
}
public Strings (String name, boolean usesBow) {
this.setName(name);
this.setFamily("String");
this.usesBow = usesBow;
}
public boolean isUsesBow() {
return usesBow;
}
public void setUsesBow(boolean usesBow) {
this.usesBow = usesBow;
}
}
class Instrument{
private String family;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFamily() {
return family;
}
public void setFamily(String family) {
this.family = family;
}
public String toString () {
System.out.println(this.getName() + " is a member of the " + this.getFamily() + " family.");
return null;
}
}