- 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 void
addItem(IItem item, int amount)
void
addItemChangeListener(ChangeListener<IItem> listener)
This is used to allow a consumer to be notified when any item is added, changed or removed.void
addItems(Map<IItem,Integer> items)
void
clearItems()
Clears all of the items from the inventory.int
getAmount(IItem item)
List<IItem>
items()
void
removeItem(IItem item)
void
removeItemChangeListener(ChangeListener<IItem> listener)
This is used to stop a consumer from receiving notifications when items are added, changed or removed.void
removeItems(List<IItem> items)
void
setAmount(IItem item, int amount)
-
-
-
Method Detail
-
items
public List<IItem> items()
- Specified by:
items
in interfaceIInventory
- Returns:
- All of the items in the inventory.
-
addItem
public void addItem(IItem item, int amount)
- Specified by:
addItem
in 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:
addItems
in interfaceIInventory
- 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 interfaceIInventory
- Parameters:
item
- The item to remove from the inventory.
-
removeItems
public void removeItems(List<IItem> items)
- Specified by:
removeItems
in interfaceIInventory
- 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 interfaceIInventory
-
getAmount
public int getAmount(IItem item)
- Specified by:
getAmount
in 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:
setAmount
in 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:IInventory
This is used to allow a consumer to be notified when any item is added, changed or removed.- Specified by:
addItemChangeListener
in 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:IInventory
This is used to stop a consumer from receiving notifications when items are added, changed or removed.- Specified by:
removeItemChangeListener
in interfaceIInventory
- Parameters:
listener
- A @see ChangeListener to be notified whenever this item is added, changed or removed.
-
-