/** * Removes the named item from the cart * * @param itemName Name of item to remove */ public void removeItems(String itemCode) { Catalog catalog = new Catalog(); // Check for item in catalog based on item code if (catalog.containsItem(itemCode)) { // Check if item is already in the cart if (contents.containsKey(itemCode)) { // remove the subscribed feed contents.remove(itemCode); } } }
/** * Adds a named item to the cart * * @param itemName The name of the item to add to the cart */ public void addItem(String itemCode) { Catalog catalog = new Catalog(); // Check for item in catalog based on item code if (catalog.containsItem(itemCode)) { Item item = catalog.getItem(itemCode); // Add the item code and item to the contents map if (!contents.containsKey(itemCode)) { contents.put(itemCode, item); } } }
/* *@param itemcode *@returns feed url associated with itemcode */ public String fetchURL(String itemCode) { Catalog catalog = new Catalog(); // Check for item in catalog based on item code if (catalog.containsItem(itemCode)) { // Check if item is already in the cart if (contents.containsKey(itemCode)) { // remove the subscribed feed Item item = contents.get(itemCode); return item.getUrl(); } } return null; }