Represents the main user in a game. Extends WObject.

package: core;

Contents

Constructors

Player()

Create a new player with a default name and description.

Player(String name)

Create a player with the given name.

Player(String name, String description)

Create a player with the given name and description.

Methods

ArrayList getInventory()

Return the list of Items in the player’s inventory.

int getScore()

Return the Player’s current score.

Room getCurrentRoom()

Return the Room in which te player currently resides.

boolean has(String name)

Returns true if name matches any item in the player’s inventory.

item getItemFromInventory(String name)

Returns the Item from the player’s inventory that matches the given name.
Returns null if the item cannot be found.

void setInventory(ArrayList inv)

Sets the player’s inventory to an already created list.

void addToInventory(Item o)

Add another item to the player’s inventory.

void clearInventory()

Remove every item from the player’s inventory.

void setScore(int s)

Set the player’s score to s.

void addToScore(int ds)

Add ds to the current score.

void setCurrentRoom(Room r)

Sets the Room in which the player currently resides.

Item removeItemFromInventory(String name)

Removes and returns the iteme with the given name from the player’s inventory.
Returns null and doesn’t modify the player’s inventory if the item cannot be found.