Class Inventory

java.lang.Object
  |
  +--Inventory

public class Inventory
extends java.lang.Object

This class maintains an inventory of UPC-coded items.


Constructor Summary
Inventory()
          Initialize a new Inventory manager.
 
Method Summary
 void addItem(UPC item)
          Add an item to the inventory
 int countItems(long code)
          Count the number of items with a particular UPC that are in stock.
 UPC findItemByUPC(long code)
          Find the first occurrence of a particular UPC coded item and return the index.
 void printInventory()
          Print all the items in inventory
 UPC removeItem(long code)
          Remove an item from the inventory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Inventory

public Inventory()
Initialize a new Inventory manager.

Method Detail

addItem

public void addItem(UPC item)
Add an item to the inventory

Parameters:
item - the item to add

removeItem

public UPC removeItem(long code)
Remove an item from the inventory

Returns:
a reference to the removed item, or null if not found

countItems

public int countItems(long code)
Count the number of items with a particular UPC that are in stock.

Returns:
the number of items found

printInventory

public void printInventory()
Print all the items in inventory


findItemByUPC

public UPC findItemByUPC(long code)
Find the first occurrence of a particular UPC coded item and return the index.

Parameters:
code - the UPC code to find
Returns:
a reference to the item or null if not found