34 : name(
"Default"), hitPoints(defaultHitPoints), energyPoints(defaultEnergyPoints),
35 attackDamage(defaultAttackDamage) {
44 : name(newName), hitPoints(defaultHitPoints), energyPoints(defaultEnergyPoints), attackDamage(defaultAttackDamage) {
53 : name(other.name), hitPoints(other.hitPoints), energyPoints(other.energyPoints), attackDamage(other.attackDamage) {
68 : name(newName), hitPoints(hp), energyPoints(ep), attackDamage(ad) {
86 hitPoints = other.hitPoints;
87 energyPoints = other.energyPoints;
88 attackDamage = other.attackDamage;
98 if (hitPoints > 0 && energyPoints > 0) {
99 std::cout <<
"ClapTrap " << name <<
" attacks " << target <<
", causing " << attackDamage
102 }
else if (hitPoints == 0) {
103 std::cout <<
"ClapTrap " << name <<
" is out of hit points and cannot attack!" <<
std::endl;
105 std::cout <<
"ClapTrap " << name <<
" is out of energy points and cannot attack!" <<
std::endl;
114 if (hitPoints == 0) {
118 std::cout <<
"ClapTrap " << name <<
" takes " << amount <<
" points of damage!" <<
std::endl;
119 if (amount >= hitPoints) {
124 std::cout <<
"ClapTrap " << name <<
" has " << hitPoints <<
" hit points remaining." <<
std::endl;
133 if (hitPoints > 0 && energyPoints > 0) {
134 std::cout <<
"ClapTrap " << name <<
" repairs itself, regaining " << amount <<
" hit points!" <<
std::endl;
137 std::cout <<
"ClapTrap " << name <<
" now has " << hitPoints <<
" hit points and " << energyPoints
139 }
else if (hitPoints == 0) {
140 std::cout <<
"ClapTrap " << name <<
" cannot be repaired as it has no hit points!" <<
std::endl;
142 std::cout <<
"ClapTrap " << name <<
" is out of energy points and cannot repair!" <<
std::endl;
Represents a basic robot character.
void beRepaired(unsigned int amount)
beRepaired function implementation.
unsigned int getHitPoints() const
Gets the current hit points of the ClapTrap.
unsigned int getAttackDamage() const
Gets the attack damage of the ClapTrap.
ClapTrap()
Default constructor implementation.
void takeDamage(unsigned int amount)
takeDamage function implementation.
void attack(const std::string &target)
Attack function implementation.
ClapTrap & operator=(const ClapTrap &other)
Copy assignment operator implementation.
~ClapTrap()
Destructor implementation.
const std::string & getName() const
Gets the name of the ClapTrap.
unsigned int getEnergyPoints() const
Gets the current energy points of the ClapTrap.
Header file for the ClapTrap class.