Class Inventory

    • Constructor Detail

      • Inventory

        public Inventory()
      • Inventory

        public Inventory​(Map<IItem,​Integer> items)
        Parameters:
        items -
    • Method Detail

      • items

        public List<IItem> items()
        Specified by:
        items in interface IInventory
        Returns:
        All of the items in the inventory.
      • addItem

        public void addItem​(IItem item,
                            int amount)
        Specified by:
        addItem in interface IInventory
        Parameters:
        item - The item to be added to the inventory.
        amount - The amount of that item to add to the inventory.
      • addItems

        public void addItems​(Map<IItem,​Integer> items)
        Specified by:
        addItems in interface IInventory
        Parameters:
        items - A map of items and there amounts to be added to the inventory.
      • removeItem

        public void removeItem​(IItem item)
        Specified by:
        removeItem in interface IInventory
        Parameters:
        item - The item to remove from the inventory.
      • removeItems

        public void removeItems​(List<IItem> items)
        Specified by:
        removeItems in interface IInventory
        Parameters:
        items - The items to remove from the inventory.
      • clearItems

        public void clearItems()
        Description copied from interface: IInventory
        Clears all of the items from the inventory.
        Specified by:
        clearItems in interface IInventory
      • getAmount

        public int getAmount​(IItem item)
        Specified by:
        getAmount in interface IInventory
        Parameters:
        item - The item you would like an amount for.
        Returns:
        How many of that item is in the inventory.
      • setAmount

        public void setAmount​(IItem item,
                              int amount)
        Specified by:
        setAmount in interface IInventory
        Parameters:
        item - The item that you would like to change the amount of.
        amount - The amount to change to.
      • addItemChangeListener

        public void addItemChangeListener​(ChangeListener<IItem> listener)
        Description copied from interface: IInventory
        This is used to allow a consumer to be notified when any item is added, changed or removed.
        Specified by:
        addItemChangeListener in interface IInventory
        Parameters:
        listener - A @see ChangeListener to be notified whenever this item is added, changed or removed.
      • removeItemChangeListener

        public void removeItemChangeListener​(ChangeListener<IItem> listener)
        Description copied from interface: IInventory
        This is used to stop a consumer from receiving notifications when items are added, changed or removed.
        Specified by:
        removeItemChangeListener in interface IInventory
        Parameters:
        listener - A @see ChangeListener to be notified whenever this item is added, changed or removed.