1   // joi/4/estore/Catalog.java                         
2   //                                                            
3   //                                                            
4   // Copyright 2003 Bill Campbell and Ethan Bolker                         
5                                                               
6   import java.util.TreeMap;
7   
8   /**
9    * A Catalog models the collection of Items that an
10   * EStore might carry.
11   *
12   * @see EStore
13   *
14   * @version 4
15   */
16  
17  public class Catalog
18  {
19      private TreeMap items;
20  
21      /**
22       *  Construct a Catalog object.
23       */
24  
25      public Catalog( ) 
26      {
27          items = new TreeMap();
28      }
29  
30      /**
31       * Add an Item to this Catalog.
32       *
33       * @param item the Item to add.
34       */
35  
36      public void addItem( Item item )
37      {
38          items.put( item.getName(), item );
39      }
40  
41      /**
42       * Get an Item from this Catalog.
43       *
44       * @param itemName the name of the wanted Item
45       *
46       * @return the Item, null if none.
47       */
48  
49      public Item getItem( String itemName ) 
50      {
51          return (Item)items.get(itemName);
52      }
53  
54      /**
55       * Display the contents of this Catalog.
56       *
57       * @param t the Terminal to print to.
58       */
59  
60      public void show( Terminal t )
61      {
62          // loop on items, printing name and cost
63          t.println("  [sorry, can't yet print Catalog contents]");
64      }    
65  }
66