 

import java.util.ArrayList;
import java.util.Iterator;

/**
 * The database class provides a facility to store CD and 
 * video objects. A list of all CDs and videos can be printed
 * to the terminal.
 *
 * This version does not save the data to disk, and it does
 * not provide any search functions.
 *
 * @author Michael Kölling and David J. Barnes
 * @version 2002-05-02
 */
public class Database
{
    private ArrayList items;
    
    /**
     * Construct an empty Database.
     */
    public Database()
    {
        items = new ArrayList();
    }
    
    /**
     * Add an item to the database.
     */
    public void addItem(Item theItem)
    {
        items.add(theItem);
    }

    /**
     * Print a list of all currently stored items to the text terminal.
     */
    public void list()
    {
        // print list of items
        for(Iterator iter = items.iterator(); iter.hasNext(); ) {
            Item item = (Item)iter.next();
            item.print();
            System.out.println();    // empty line between items
        }
    }
}
