import java.awt.*;
import java.util.*;

/**
 * Using our first collection - ArrayList
 * 
 * 1) Show the basics
 * 2) Try out: clear, remove, contains, and indexOf
 * 3) Go back to lecture to show boxing
 * 
 * @author McKinley
 * @version April 2007
 */
public class Inventory
{

    public static void main (String [] args)
    {   
        ArrayList<Items> apples = new ArrayList<Items>();
        Items a = new Items ("Ruby Red", 109);
        apples.add(a);
        a = new Items ("McIntosh", 8);
        apples.add(a);
        a = new Items ("Gala", 88);
        apples.add(0, a);
    //    apples.set(100,a); Out of Bounds Error
        
        System.out.println();
        for (int i = 0; i < apples.size(); i++) {
            System.out.println(apples.get(i));            
        }
        
        /* Short hand for same iterating through an ArrayList
         * 
         * for (<type> <variable name> : <ArrayList name>) {
         *    <statement> 
         *    ....
         *    <statement>
         * }

         * 
         */ 
        
         for (Items item: apples) {
             System.out.println(item);
         }
        
        // Integer lists        
        ArrayList<Integer> amounts = new ArrayList<Integer>();
        Integer box = new Integer(1);
        amounts.add(box);
        int j = 10;
        amounts.add(j);   //automatically boxed and unboxed
        amounts.add(0,1000);
        amounts.add(101);
        for (Integer bx: amounts) {
            System.out.println(bx);
        }
    }

}
