- java.lang.Object
-
- playerlib.inventory.Inventory
-
- All Implemented Interfaces:
IInventory
public class Inventory extends Object implements IInventory
- Author:
- Jeff Riggle
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddItem(IItem item, int amount)voidaddItemChangeListener(ChangeListener<IItem> listener)This is used to allow a consumer to be notified when any item is added, changed or removed.voidaddItems(Map<IItem,Integer> items)voidclearItems()Clears all of the items from the inventory.intgetAmount(IItem item)List<IItem>items()voidremoveItem(IItem item)voidremoveItemChangeListener(ChangeListener<IItem> listener)This is used to stop a consumer from receiving notifications when items are added, changed or removed.voidremoveItems(List<IItem> items)voidsetAmount(IItem item, int amount)
-
-
-
Method Detail
-
items
public List<IItem> items()
- Specified by:
itemsin interfaceIInventory- Returns:
- All of the items in the inventory.
-
addItem
public void addItem(IItem item, int amount)
- Specified by:
addItemin interfaceIInventory- 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:
addItemsin interfaceIInventory- Parameters:
items- A map of items and there amounts to be added to the inventory.
-
removeItem
public void removeItem(IItem item)
- Specified by:
removeItemin interfaceIInventory- Parameters:
item- The item to remove from the inventory.
-
removeItems
public void removeItems(List<IItem> items)
- Specified by:
removeItemsin interfaceIInventory- Parameters:
items- The items to remove from the inventory.
-
clearItems
public void clearItems()
Description copied from interface:IInventoryClears all of the items from the inventory.- Specified by:
clearItemsin interfaceIInventory
-
getAmount
public int getAmount(IItem item)
- Specified by:
getAmountin interfaceIInventory- 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:
setAmountin interfaceIInventory- 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:IInventoryThis is used to allow a consumer to be notified when any item is added, changed or removed.- Specified by:
addItemChangeListenerin interfaceIInventory- 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:IInventoryThis is used to stop a consumer from receiving notifications when items are added, changed or removed.- Specified by:
removeItemChangeListenerin interfaceIInventory- Parameters:
listener- A @see ChangeListener to be notified whenever this item is added, changed or removed.
-
-