-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharacter.cpp
More file actions
21 lines (17 loc) · 782 Bytes
/
Character.cpp
File metadata and controls
21 lines (17 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "Character.h"
// Constructor for the Character class, initializing the character with a name, description,
// and default values for health, attack, move, and initiative.
Character::Character(const std::string &n, const std::string &d)
: GameObject(n, d), health(100), attack(10), move(5), initiative(1) {}
// Getter method for the health attribute. Returns the current health of the character.
int Character::getHealth() const {
return health;
}
// Setter method for the health attribute. Sets the character's health to the provided value.
void Character::setHealth(int health) {
this->health = health;
}
// Getter method for the attack attribute. Returns the current attack value of the character.
int Character::getAttack() const {
return attack;
}