COMP2396
Loading...
Searching...
No Matches
assignment2.Student Class Reference

The Student is poor and can only afford using a BadGun. More...

Inheritance diagram for assignment2.Student:
Collaboration diagram for assignment2.Student:

Public Member Functions

 Student (String name, int energyLevel, int skillLevel)
 Constructs a new Student with the specified name, energy level, and skill level.
 
void hide ()
 Hides the student from the next attack.
 
int hurt (int attackAmount)
 Calculates the amount of hurt taken from an attack.
 
- Public Member Functions inherited from assignment2.Character
 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.
 
boolean isLose ()
 Determines whether the character has lost the combat.
 

Private Attributes

boolean isHidden = false
 

Detailed Description

The Student is poor and can only afford using a BadGun.

However, he/she can hide to dodge an attack and receive 0 hurt. It is a subclass of the Character class.

Definition at line 8 of file Student.java.

Constructor & Destructor Documentation

◆ Student()

assignment2.Student.Student ( String name,
int energyLevel,
int skillLevel )
inline

Constructs a new Student with the specified name, energy level, and skill level.

Parameters
namethe name of the student
energyLevelthe initial energy level of the student
skillLevelthe skill level of the student

Definition at line 18 of file Student.java.

18 {
19 super(name, energyLevel, skillLevel);
20 }

References assignment2.Character.energyLevel, and assignment2.Character.skillLevel.

Member Function Documentation

◆ hide()

void assignment2.Student.hide ( )
inline

Hides the student from the next attack.

When hidden, the student takes no damage.

Definition at line 25 of file Student.java.

25 {
26 isHidden = true;
27 }

References assignment2.Student.isHidden.

Referenced by assignment2.OfficeCombat2.main().

Here is the caller graph for this function:

◆ hurt()

int assignment2.Student.hurt ( int attackAmount)
inline

Calculates the amount of hurt taken from an attack.

If the student is hidden, they take no damage. Otherwise, reduces the energy level by the attack amount.

Parameters
attackAmountthe amount of attack received
Returns
the actual amount of energy reduced from the attack

Reimplemented from assignment2.Character.

Definition at line 38 of file Student.java.

38 {
39 if (isHidden) {
40 isHidden = false;
41 return 0;
42 } else {
43 return super.hurt(attackAmount);
44 }
45 }

References assignment2.Student.isHidden.

Referenced by assignment2.OfficeCombat2.main().

Here is the caller graph for this function:

Member Data Documentation

◆ isHidden

boolean assignment2.Student.isHidden = false
private

Definition at line 9 of file Student.java.

Referenced by assignment2.Student.hide(), and assignment2.Student.hurt().


The documentation for this class was generated from the following file: