|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectes.ucm.fdi.hysteria.game.ItemRepository
public class ItemRepository
An inventory stores the items the player picks during the game. The inventory can be examined, presenting the names of the objects contained in it. Additionally, we can examine a single object in the inventory.
Field Summary | |
---|---|
protected java.util.Set<Item> |
_items
The collection that stores the items collected by the player |
Constructor Summary | |
---|---|
ItemRepository()
Creates a new, empty inventory |
Method Summary | |
---|---|
void |
addItem(Item newItem)
Adds a new item to the inventory, if there is no item with the same name |
void |
clear()
Clears the repository. |
java.lang.Object |
clone()
|
java.util.Set<Item> |
getAllItems()
Gets all items from the repository. |
java.util.Set<Item> |
getItems(java.lang.String name)
Gets items by name from the repository. |
int |
getTotalValue()
Computes the total number of points provided by the items stored in the inventory |
float |
getTotalWeight()
Computes the total weight of actual item repository |
boolean |
hasItem(Item item)
Checks whether the repository contains an specific item. |
boolean |
isEmpty()
Checks whether the repository is empty. |
void |
removeItem(Item item)
Removes an item from the repository. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.Set<Item> _items
Constructor Detail |
---|
public ItemRepository()
Method Detail |
---|
public void addItem(Item newItem) throws java.lang.IllegalArgumentException, ItemAlreadyInRepositoryException
newItem
- The item that can be stored in the inventory
java.lang.IllegalArgumentException
ItemAlreadyInRepositoryException
public java.util.Set<Item> getAllItems()
public java.util.Set<Item> getItems(java.lang.String name) throws java.lang.IllegalArgumentException
name
- The name.
java.lang.IllegalArgumentException
- Argument 'name' cannot be null.public int getTotalValue()
public float getTotalWeight()
public boolean isEmpty()
public void clear()
public void removeItem(Item item) throws java.lang.IllegalArgumentException, ItemNotInRepositoryException
item
- The item.
java.lang.IllegalArgumentException
- Argument 'item' cannot be null.
ItemNotInRepositoryException
- Item public java.lang.String toString()
toString
in class java.lang.Object
public boolean hasItem(Item item) throws java.lang.IllegalArgumentException
item
- The item.
java.lang.IllegalArgumentException
public java.lang.Object clone()
clone
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |