|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Creature
public class Creature
This class represents a Creature within our game. For full details of the Creature class, see HW J6.
Constructor Summary | |
---|---|
Creature()
Creates a default creature. |
|
Creature(int hp,
int str,
int skl,
int ac,
java.lang.String name,
java.lang.String type,
java.lang.String pronoun)
Creates a creature with the attributes set to the passed values. |
Method Summary | |
---|---|
int |
calcHitDamage()
Calculates how much damage the creature did on a successful attack. |
java.lang.String |
constructHitString(Creature other)
Returns a String stating that the creature successfully hit the passed opponent. |
java.lang.String |
constructMissString(Creature other)
Returns a String stating that the creature successfully missed the passed opponent. |
boolean |
getAngry()
Returns whether the creature is angry or not |
int |
getArmorClass()
Gets the creature's armor class |
int |
getHitPoints()
Gets the creature's hit points |
java.lang.String |
getName()
Gets the creature's name (i.e., 'Frodo') |
java.lang.String |
getPronoun()
Gets the creature's pronoun (i.e., 'his', her', 'its', etc.) |
int |
getSkill()
Gets the creature's skill level |
int |
getStrength()
Gets the creature's strength |
java.lang.String |
getType()
Gets the creature's type (i.e., 'hobbit') |
Weapon |
getWeapon()
Gets the creature's weapon |
boolean |
isAlive()
Returns whether the creature is still alive or not. |
void |
setAngry()
Sets the creature to be angry. |
void |
setAngry(boolean toWhat)
Sets the creature to be angry. |
void |
setArmorClass(int ac)
Sets the creature's armor class |
void |
setHitPoints(int hp)
Sets the creature's hit points |
void |
setName(java.lang.String nm)
Sets the creature's name (i.e., 'Frodo') |
void |
setPronoun(java.lang.String pn)
Sets the creature's pronoun (i.e., 'his', her', 'its', etc.) |
void |
setSkill(int skl)
Sets the creature's skill |
void |
setStrength(int str)
Sets the creature's strength |
void |
setType(java.lang.String tp)
Sets the creature's type (i.e, 'hobbit') |
void |
setWeapon(Weapon w)
Sets the creature's weapon |
void |
takeDamage(int damage)
Causes the creature to take the passed amount of damage. |
boolean |
tryToAttack(int targetAC)
Returns whether the creature successfully managed to attack a target with the passed armor class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Creature()
public Creature(int hp, int str, int skl, int ac, java.lang.String name, java.lang.String type, java.lang.String pronoun)
hp
- How many hit points this creature should havestr
- The creature's strengthskl
- The creature's skill levelac
- The creature's armor classname
- The creature's name (i.e., 'Frodo')type
- The creature's type (i.e., 'hobbit')pronoun
- The pronoun for the creature (i.e., 'his', her',
'its', etc.)Method Detail |
---|
public boolean getAngry()
public void setAngry()
public void setAngry(boolean toWhat)
toWhat
- Whether the creature should be set to angry or
not.public int getHitPoints()
public int getStrength()
public int getSkill()
public int getArmorClass()
public java.lang.String getName()
public java.lang.String getType()
public java.lang.String getPronoun()
public Weapon getWeapon()
public void setHitPoints(int hp)
hp
- The creature's hit pointspublic void setStrength(int str)
str
- The creature's strengthpublic void setSkill(int skl)
skl
- The creature's skillpublic void setArmorClass(int ac)
ac
- The creature's armor classpublic void setName(java.lang.String nm)
nm
- The creature's namepublic void setType(java.lang.String tp)
tp
- The creature's namepublic void setPronoun(java.lang.String pn)
pn
- The creature's pronounpublic void setWeapon(Weapon w)
w
- The creature's weaponpublic boolean isAlive()
public boolean tryToAttack(int targetAC)
targetAC
- The target armor class of the creature's opponent
public int calcHitDamage()
Weapon.getDamageModifier()
and a random number based on
the creature's strength.
public void takeDamage(int damage)
damage
- How much damage this creature took.public java.lang.String constructHitString(Creature other)
other
- The creature's opponent. This is needed for part
of the returned hit string.
public java.lang.String constructMissString(Creature other)
other
- The creature's opponent. This is needed for part
of the returned miss string.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |