1//CodeHS AP Computer Science A Java, 9.2.7: Instruments
2//DO NOT COPY AND PASTE, YOUR TEACHER CAN SEE YOUR EDIT HISTORY.
3//Part 2/3
4//Instrument.java
5
6public class Instrument
7{
8 String name = "";
9 String family = "";
10
11 public Instrument(String name, String family){
12 this.name = name;
13 this.family = family;
14 }
15
16 public Instrument(String name){
17 this.name = name;
18 }
19
20 public void setName(String str){
21 this.name = str;
22 }
23
24 public String getName(){
25 return this.name;
26 }
27
28 public void setFamily(String str){
29 this.family = str;
30 }
31
32 public String getFamily(){
33 return this.family;
34 }
35
36 public String toString(){
37 return name + " is a member of the " + family + " family.";
38 }
39
40}
41
1//CodeHS AP Computer Science A Java, 9.2.7: Instruments
2//DO NOT COPY AND PASTE, YOUR TEACHER CAN SEE YOUR EDIT HISTORY.
3//Part 3/3
4//Strings.java
5
6public class Strings extends Instrument
7{
8
9 public Strings(String name, String family, boolean bow){
10 super(name, family);
11 this.bow = bow;
12 }
13
14 public Strings(String name, boolean bow){
15 super(name, "Strings");
16 this.bow = bow;
17 }
18
19 boolean bow;
20
21 public boolean getBow(){
22 return this.bow;
23 }
24
25 public void setBow(boolean bool){
26 this.bow = bool;
27 }
28}
1//CodeHS AP Computer Science A Java, 9.2.7: Instruments
2//DO NOT COPY AND PASTE, YOUR TEACHER CAN SEE YOUR EDIT HISTORY.
3//Part 1/3
4//Wind.java
5
6public class Wind extends Instrument
7{
8 boolean reed;
9
10 public Wind(String name, String family, boolean reed){
11 super(name, family);
12 this.reed = reed;
13 }
14
15 public boolean getReed(){
16 return reed;
17 }
18
19 public void setReed(boolean bool){
20 this.reed = bool;
21 }
22
23}
24