CodeHS java 9.5.6 code example

Example: 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());
        }
    }
}

Tags:

Misc Example