CodeHS java 9.2.7

//CodeHS AP Computer Science A Java, 9.2.7: Instruments
//DO NOT COPY AND PASTE, YOUR TEACHER CAN SEE YOUR EDIT HISTORY.
//Part 1/3
//Wind.java 

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;
    }
 
}

4
4
XRii 95 points

                                    //CodeHS AP Computer Science A Java, 9.2.7: Instruments
//DO NOT COPY AND PASTE, YOUR TEACHER CAN SEE YOUR EDIT HISTORY.
//Part 3/3
//Strings.java

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;
    }
}

4 (4 Votes)
0
4.14
7
GregDoesMath 115 points

                                    //CodeHS AP Computer Science A Java, 9.2.7: Instruments
//DO NOT COPY AND PASTE, YOUR TEACHER CAN SEE YOUR EDIT HISTORY.
//Part 2/3
//Instrument.java

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.";
    }
    
}

4.14 (7 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source