codehs java 9.2.7 code example
Example 1: CodeHS java 9.2.7
public class Wind extends Instrument
{
boolean reed;
public Wind(String name, String family, boolean reed){
super(name, family);
this.reed = reed;
}
public boolean getReed(){
return reed;
}
public void setReed(boolean bool){
this.reed = bool;
}
}
Example 2: CodeHS java 9.2.7
public class Strings extends Instrument
{
public Strings(String name, String family, boolean bow){
super(name, family);
this.bow = bow;
}
public Strings(String name, boolean bow){
super(name, "Strings");
this.bow = bow;
}
boolean bow;
public boolean getBow(){
return this.bow;
}
public void setBow(boolean bool){
this.bow = bool;
}
}
Example 3: CodeHS java 9.2.7
public class Instrument
{
String name = "";
String family = "";
public Instrument(String name, String family){
this.name = name;
this.family = family;
}
public Instrument(String name){
this.name = name;
}
public void setName(String str){
this.name = str;
}
public String getName(){
return this.name;
}
public void setFamily(String str){
this.family = str;
}
public String getFamily(){
return this.family;
}
public String toString(){
return name + " is a member of the " + family + " family.";
}
}