Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

packagetemplates; importjava.util.*; public classTemplates1Main { /** * @param a

ID: 3617448 • Letter: P

Question

packagetemplates;

importjava.util.*;

public classTemplates1Main
{

    /**
     * @param args the command linearguments
     */
    public static void main(String[] args)
    {
        /**
         * Create anArrayList of Products
         */
       ArrayList<Product>ts = new ArrayList<Product>();
        ts.add(newProduct("Maury", "Spearman", 34, "Java", 25.00));
        //ts.add("hello");
        ts.add(newProduct("Elizabeth", "Walker", 34, "Java", 35.00));
        for(inti=0;i<2;i++)
       ts.get(i).display();     //alternative;
       //ts.get(1).display();     //

       //arr.remove("Rahul");

       //System.out.println("Index of 6.7: " +arr.indexOf(6.7));
       // System.out.println("Elementat Index 0: " +arr.get(0));
        Iterator<Product>i = ts.iterator();      //Creating anIterator which only works on products
        while(i.hasNext())
        {
           Product p = i.next();
           p.display();
        }
   }

}
abstract class Product
{
    protected int age;
    protected String FName;
    protected String LName;

    publicProduct(String fn, String ln, int ag)
    {
        FName = fn;
        LName = ln;
        age = ag;
    }
    public abstract void display();
}

class Books extendsProduct
{
     private String bookType;
     private double price;
    
     public Books(String fname, String lname,int ag, String bktype, double pric)
     {
         super(fname,lname, ag);
         bookType =bktype;
         price =pric;       
     }
     public void display()
     {
        System.out.printf("%15s %15s %15d %15s %15.2f", FName, LName, age,bookType, price);
     }
}

Explanation / Answer

Please disregard this question, I got it. thanks