Answers for "CodeHS Java 9.2.6"

0

CodeHS java 9.5.6

//CodeHS AP Computer Science A Java, 9.5.6: Pies
//DO NOT COPY AND PASTE, YOUR TEACHER CAN SEE YOUR EDIT HISTORY.

//PieTester.java

import java.util.ArrayList;

public class PieTester
{
    public static void main(String[] args)
    {
        ArrayList<Pie> pies = new ArrayList<Pie>();
        Pie applPie = new ApplePie(7);
        Pie pumpPie = new PumpkinPie(7, true);
        Pie pie = new Pie("blueberry", 7);
        
        pies.add(applPie);
        pies.add(pumpPie);
        pies.add(pie);
        
        for(int i = 0; i < pies.size(); i++){
            System.out.print("Pie: ");
            System.out.println(pies.get(i).getType());
        }
    }
}
Posted by: Guest on April-27-2021
0

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 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.";
    }
    
}
Posted by: Guest on April-20-2021
0

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;
    }
 
}
Posted by: Guest on April-20-2021
0

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 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;
    }
}
Posted by: Guest on April-20-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language