Class Person

java.lang.Object
  extended by Person

public class Person
extends java.lang.Object


Field Summary
private  int health
          The person's health
private  boolean isAlive
          Is the person alive? If yes, the value is true.
private  java.lang.String name
          The person's name
 
Constructor Summary
Person(java.lang.String name)
          Specific constructor
 
Method Summary
 void changeHealth(int byHowMuch)
          Changes the health of the person by the amount specified.
 int getHealth()
           
 boolean getIsAlive()
           
 java.lang.String getName()
           
 void setHealth(int health)
           
 void setIsAlive(boolean isAlive)
           
 void setName(java.lang.String name)
           
 java.lang.String toString()
          Print method for Person
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

private java.lang.String name
The person's name


health

private int health
The person's health


isAlive

private boolean isAlive
Is the person alive? If yes, the value is true. If no, the value is false.

Constructor Detail

Person

public Person(java.lang.String name)
Specific constructor

Parameters:
name - The name to initialize for the person
Method Detail

getHealth

public int getHealth()
Returns:
Returns the health.

setHealth

public void setHealth(int health)
Parameters:
health - The health to set.

getIsAlive

public boolean getIsAlive()
Returns:
Returns isAlive's value.

setIsAlive

public void setIsAlive(boolean isAlive)
Parameters:
isAlive - The isAlive to set.

getName

public java.lang.String getName()
Returns:
Returns the name.

setName

public void setName(java.lang.String name)
Parameters:
name - The name to set.

changeHealth

public void changeHealth(int byHowMuch)
Changes the health of the person by the amount specified. If health is less than or equal to zero, notifies the player that the Person has died and checks whether to end the game.

Parameters:
byHowMuch - How much to change the Person's health by

toString

public java.lang.String toString()
Print method for Person

Overrides:
toString in class java.lang.Object
Returns:
A string representing the status of the person. It includes the Person's name, their health, and whether they are alive or dead