import java.util.*;
/**
 * Use ArrayList class to Implement GroceryList
 * @author Suzanne Balik, 30 Jan 2004
 */
public class GroceryList {
 
  private ArrayList groceries;
  
  public GroceryList() {
  
    groceries = new ArrayList();

  }
 
 
   
  public boolean isEmpty() {
   
    return groceries.isEmpty();
   
  } 
  
  public void addItem(String item) {
   
      groceries.add(item);
  }
 
 
  public int numberOfItems() {
   
    return groceries.size();
   
  }
   
  public String toString() {
   
    String s = "";
        
    for (int i = 0; i < groceries.size(); i++)
     
      s += groceries.get(i) + "\n";
   
    return s;
  }
   
  public void clear() {
   
    groceries.clear();
  }
   
  public static void main(String[] args) {
   
    //Create a new grocery list
    GroceryList myList = new GroceryList();
     
    //Add some items
    myList.addItem("eggs");
    myList.addItem("bacon");
    myList.addItem("orange juice");
    myList.addItem("coffee");
     
    //Print out the list
    System.out.println("\n" + myList);
     
    //Print number of items in list
    System.out.println("Number of items: " + 
                        myList.numberOfItems());
			
    //Is list empty?
    System.out.println("Empty?: " + myList.isEmpty());
			
    //Clear list
    myList.clear();
    
    //Print number of items in list
    System.out.println("\nNumber of items: " + 
                        myList.numberOfItems()); 
    //Is list empty OR full?
    System.out.println("Empty?: " + myList.isEmpty());
			
    //Add some items
    myList.addItem("beer");
    myList.addItem("chips");
    myList.addItem("salsa");
    
    System.out.println("\n" + myList);     
  }
} 

/* PROGRAM OUTPUT:

csc% java GroceryList

eggs
bacon
orange juice
coffee

Number of items: 4
Empty?: false
Full?: false

Number of items: 0
Empty?: true
Full?: false

beer
chips
salsa

*/