001    package market;
002    
003    import data.CatalogItem;
004    import data.ooimpl.CatalogImpl;
005    
006    /**
007     * A CatalogImpl, where the CIArticles of the market are stored. The market's offer, and therefore
008     * this catalog, never changes.
009     */
010    public class CArticleCatalog extends CatalogImpl {
011    
012        /**
013         * @param name the ID of the CArticleCatalog
014         */
015        public CArticleCatalog(String name) {
016            super(name);
017        }
018    
019        /**
020         * Adds a CatalogItem to the catalog. Used as a shortcut for <code>add(item, null)</code>.
021         * @param item the CatalogItem to be added.
022         */
023        public void add(CatalogItem item) {
024            add(item, null);
025        }
026    
027        /**
028         * Removes a CatalogItem from the catalog. Used as a shortcut for <code>remove(name, null)</code>
029         * including the try-catch-block.
030         * @param name the name of the CatalogItem to be removed.
031         */
032        public void remove(String name) {
033            try {
034                remove(name, null);
035            }
036            catch (Exception e) {
037                System.err.println(e.getMessage());
038            }
039        }
040    
041        /**
042         * Gets a CatalogItem by its name. Used as a shortcut for <code>get(name, null)</code>
043         * including the try-catch-block.
044         *
045         * @param name the name of the searched CatalogItem.
046         * @return the searched CatalogItem if found, otherwise <code>null</code>.
047         */
048        public CIArticle get(String name) {
049            try {
050                return (CIArticle)get(name, null, false);
051            }
052            catch (Exception e) {
053                System.err.println(e.getMessage());
054                return null;
055            }
056        }
057    }