Package cs2110
Class Player
java.lang.Object
cs2110.Player
- All Implemented Interfaces:
Actor
A player in our game simulation that accepts console input on each turn to determine which
monster to attack.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe starting health level of a monster. -
Constructor Summary
ConstructorsConstructorDescriptionPlayer(String name, String species, GameEngine engine) Constructs a new player with the given `name` and `species` and initializes its health and power levels. -
Method Summary
Modifier and TypeMethodDescriptionvoidLaunches an attack against the given `target`.booleandefend(int atk) Responds to an attack with the given `atk` roll.inthealth()Returns the current health level for this Actor.name()Returns the name of this Actor.intpower()Returns the base power level for this Actor.species()Returns the species of this player.voidtakeTurn()Queries the user for which living monster they'd like to attack and then launches an attack against that monster.
-
Field Details
-
STARTING_HEALTH
public static final int STARTING_HEALTHThe starting health level of a monster.- See Also:
-
-
Constructor Details
-
Player
Constructs a new player with the given `name` and `species` and initializes its health and power levels.
-
-
Method Details
-
takeTurn
public void takeTurn()Queries the user for which living monster they'd like to attack and then launches an attack against that monster. -
attack
Description copied from interface:ActorLaunches an attack against the given `target`. -
defend
public boolean defend(int atk) Description copied from interface:ActorResponds to an attack with the given `atk` roll. Returns `true` if the defense succeeded, false otherwise. -
name
Description copied from interface:ActorReturns the name of this Actor. -
species
Returns the species of this player. -
health
public int health()Description copied from interface:ActorReturns the current health level for this Actor. -
power
public int power()Description copied from interface:ActorReturns the base power level for this Actor.
-