org.haphazard.character.inventory
Class Inventory

java.lang.Object
  extended byorg.haphazard.character.inventory.Inventory
All Implemented Interfaces:
Containing

public class Inventory
extends java.lang.Object
implements Containing

Convenience class for handling the inventory


Constructor Summary
Inventory()
          Creates a new instance of Inventory
 
Method Summary
 boolean add(Item item)
          Adds an item to this container
 void addContainer(Containing container)
          Adds a container to the inventory
 boolean canHold(Item item)
          Checks if this container can hold the specified item
 boolean contains(Item item)
          Checks if this container contains this item
 Dimension3D getContainerDimension()
          Gets the total volume of the container
 int getContainerWeight()
          Gets the total weight of the container
 int getFreeSpecializationSlots()
          Gets the number of free slots
 int getFreeVolume()
          Gets the total free volume of the inventory
 javax.swing.tree.DefaultMutableTreeNode getTreeNode()
          Gets the treenode of the containing item
 boolean isSpecialization(Item item)
          Checks if an item is a specialization of this container
 boolean remove(Item item)
          Removes an item from this container
 void removeContainer(Containing container)
          Removes a container to the inventory
 void setAlgorithm(InventoryAlgorithm algorithm)
          Sets the algorithm to be used for this inventory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Inventory

public Inventory()
Creates a new instance of Inventory

Method Detail

setAlgorithm

public void setAlgorithm(InventoryAlgorithm algorithm)
Sets the algorithm to be used for this inventory

Parameters:
algorithm - The algorithm to use

add

public boolean add(Item item)
Adds an item to this container

Specified by:
add in interface Containing
Parameters:
item - The item to add
Returns:
True if the the add went ok

addContainer

public void addContainer(Containing container)
Adds a container to the inventory

Parameters:
container - The container to add

remove

public boolean remove(Item item)
Removes an item from this container

Specified by:
remove in interface Containing
Parameters:
item - The item to remove
Returns:
True if the remove went ok

removeContainer

public void removeContainer(Containing container)
Removes a container to the inventory

Parameters:
container - The container to remove

canHold

public boolean canHold(Item item)
Checks if this container can hold the specified item

Specified by:
canHold in interface Containing
Parameters:
item - The item to check against
Returns:
True if the container can hold the item

contains

public boolean contains(Item item)
Checks if this container contains this item

Specified by:
contains in interface Containing
Parameters:
item - The item to check for
Returns:
True if the item is in this container

getContainerDimension

public Dimension3D getContainerDimension()
Gets the total volume of the container

Specified by:
getContainerDimension in interface Containing
Returns:
The total volume of the container

getFreeVolume

public int getFreeVolume()
Gets the total free volume of the inventory

Specified by:
getFreeVolume in interface Containing
Returns:
The total free volume of the inventory

getContainerWeight

public int getContainerWeight()
Gets the total weight of the container

Specified by:
getContainerWeight in interface Containing
Returns:
The total weight of the container

getTreeNode

public javax.swing.tree.DefaultMutableTreeNode getTreeNode()
Gets the treenode of the containing item

Specified by:
getTreeNode in interface Containing
Returns:
The node of the container to be used in a JTree

getFreeSpecializationSlots

public int getFreeSpecializationSlots()
Description copied from interface: Containing
Gets the number of free slots

Specified by:
getFreeSpecializationSlots in interface Containing
Returns:
Gets the number of free specialization slots on this container

isSpecialization

public boolean isSpecialization(Item item)
Description copied from interface: Containing
Checks if an item is a specialization of this container

Specified by:
isSpecialization in interface Containing
Parameters:
item - The item to check