COMP2396
|
The Character class represents any game character with a name, skill level, and energy level. More...
Public Member Functions | |
Character (String name, int energyLevel, int skillLevel) | |
Constructs a new Character with the specified name, energy level, and skill level. | |
int | attack (Weapon w1) |
Calculates the total attack amount generated by the character. | |
int | getEnergyLevel () |
Returns the current energy level of the character. | |
String | getName () |
Returns the name of the character. | |
int | getSkillLevel () |
Returns the skill level of the character. | |
int | hurt (int attackAmount) |
Reduces the energy level of the character by the specified attack amount. | |
boolean | isLose () |
Determines whether the character has lost the combat. | |
Private Attributes | |
final String | characterName |
int | energyLevel |
final int | skillLevel |
The Character class represents any game character with a name, skill level, and energy level.
A character can attack using a weapon and can be hurt by attacks.
Definition at line 7 of file Character.java.
|
inline |
Constructs a new Character with the specified name, energy level, and skill level.
name | the name of the character |
energyLevel | the initial energy level of the character |
skillLevel | the skill level of the character |
Definition at line 19 of file Character.java.
References assignment2.Character.energyLevel, and assignment2.Character.skillLevel.
|
inline |
Calculates the total attack amount generated by the character.
It is the sum of the weapon's power and the character's skill level.
w1 | the weapon used for the attack |
Definition at line 70 of file Character.java.
References assignment2.Weapon.shoot(), and assignment2.Character.skillLevel.
Referenced by assignment2.OfficeCombat1.main(), and assignment2.OfficeCombat2.main().
|
inline |
Returns the current energy level of the character.
Definition at line 48 of file Character.java.
References assignment2.Character.energyLevel.
Referenced by assignment2.OfficeCombat1.main(), and assignment2.OfficeCombat2.main().
|
inline |
Returns the name of the character.
Definition at line 30 of file Character.java.
References assignment2.Character.characterName.
Referenced by assignment2.OfficeCombat1.main(), and assignment2.OfficeCombat2.main().
|
inline |
Returns the skill level of the character.
Definition at line 39 of file Character.java.
References assignment2.Character.skillLevel.
Referenced by assignment2.OfficeCombat1.main(), and assignment2.OfficeCombat2.main().
|
inline |
Reduces the energy level of the character by the specified attack amount.
attackAmount | the amount of energy to reduce |
Reimplemented in assignment2.Student.
Definition at line 58 of file Character.java.
Referenced by assignment2.OfficeCombat1.main(), and assignment2.OfficeCombat2.main().
|
inline |
Determines whether the character has lost the combat.
A character loses if their energy level is zero or below.
Definition at line 80 of file Character.java.
Referenced by assignment2.OfficeCombat1.main(), and assignment2.OfficeCombat2.main().
|
private |
Definition at line 8 of file Character.java.
Referenced by assignment2.Character.getName().
|
private |
Definition at line 10 of file Character.java.
Referenced by assignment2.Character.Character(), assignment2.SecurityGuard.SecurityGuard(), assignment2.Student.Student(), and assignment2.Character.getEnergyLevel().
|
private |
Definition at line 9 of file Character.java.
Referenced by assignment2.Character.Character(), assignment2.SecurityGuard.SecurityGuard(), assignment2.Student.Student(), assignment2.Character.attack(), and assignment2.Character.getSkillLevel().