Class Player
java.lang.Object
org.progettoedids.entities.Entity
org.progettoedids.entities.players.Player
A Player is an Entity which is characterized by a certain
health and an Inventory.
The Player starts with a certain health and can lose and gain it, if the Player's health reaches or goes
below zero then the Player is considered dead, no limits are set on the amount of health it can gain.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddecreaseHealth(int amount) Decreases the health of the Player by a certain amount.intReturns the health of the Player.Returns the inventory of the Player.voidincreaseHealth(int amount) Increases the health of the Player by a certain amount.voidsetHealth(int health) Sets the health of the Player.toString()Methods inherited from class org.progettoedids.entities.Entity
getName, getSystemName, getUUID, setName
-
Field Details
-
inventory
-
-
Constructor Details
-
Player
Initializes Player.- Parameters:
systemName- The system name is used to uniquely identify a certain type of Food. Must not be nullname- The name is displayed to the user and is used to identify an instance of Food by the user. Must not be nullhealth- the initial health of the Player. Must be positiveinventory- the inventory of the Player. Must not be null
-
-
Method Details
-
getInventory
Returns the inventory of the Player.- Returns:
- the Inventory object of the Player
-
getHealth
public int getHealth()Returns the health of the Player.- Returns:
- a positive integer
-
setHealth
Sets the health of the Player.- Parameters:
health- the new health of the Player. Must be a positive or zero- Throws:
DeathException- if the new health is set to zero
-
increaseHealth
public void increaseHealth(int amount) Increases the health of the Player by a certain amount.- Parameters:
amount- the amount of health to add to the player. Must be positive or zero- Throws:
IllegalArgumentException- if the amount passed as an argument is negative
-
decreaseHealth
Decreases the health of the Player by a certain amount.- Parameters:
amount- the amount of health to remove from the player. Must be positive or zero- Throws:
IllegalArgumentException- if the amount passed as an argument is negativeDeathException- if the health of the Player reaches or goes below zero
-
toString
-