Class ItemService
Object
ItemService
Specific bean for the dropping, getting, selling and buying of items from
containers, from rooms and from persons.
- Author:
- maartenl
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuy
(Item item, User aUser, Shopkeeper shopkeeper) Buys an item from a shopkeeper.createItem
(long itemdefnr) boolean
Drops an item on the floor.boolean
Gets an item from off the floor/room.protected EntityManager
Returns the entity manager of JPA.boolean
Gives an item from one person to another person.boolean
Puts an item into a container.boolean
Retrieves an item from a container.sell
(Item item, User aUser, Shopkeeper shopkeeper) Sells an item from a user to a shopkeeper.
-
Constructor Details
-
ItemService
-
-
Method Details
-
getEntityManager
protected EntityManager getEntityManager()Returns the entity manager of JPA. This is defined in build/web/WEB-INF/classes/META-INF/persistence.xml.- Returns:
- EntityManager
-
drop
-
get
-
give
-
put
-
retrieve
-
sell
Sells an item from a user to a shopkeeper.- Parameters:
item
- the item to be soldaUser
- the user selling the itemshopkeeper
- the shopkeeper buying the item- Returns:
- the amount of money transferred, or Null if it was unsuccessful.
-
buy
Buys an item from a shopkeeper.- Parameters:
item
- the item to be boughtaUser
- the user buying the itemshopkeeper
- the shopkeeper selling the item- Returns:
- the amount of money transferred, or Null if it was unsuccessful.
-
createItem
-