33ClapTrap::ClapTrap() : name(
"Default"), hitPoints(10), energyPoints(10), attackDamage(0) {
50 : name(other.name), hitPoints(other.hitPoints), energyPoints(other.energyPoints), attackDamage(other.attackDamage) {
68 hitPoints = other.hitPoints;
69 energyPoints = other.energyPoints;
70 attackDamage = other.attackDamage;
80 if (hitPoints > 0 && energyPoints > 0) {
81 std::cout <<
"ClapTrap " << name <<
" attacks " << target <<
", causing " << attackDamage
84 }
else if (hitPoints == 0) {
85 std::cout <<
"ClapTrap " << name <<
" is out of hit points and cannot attack!" <<
std::endl;
87 std::cout <<
"ClapTrap " << name <<
" is out of energy points and cannot attack!" <<
std::endl;
100 std::cout <<
"ClapTrap " << name <<
" takes " << amount <<
" points of damage!" <<
std::endl;
101 if (amount >= hitPoints) {
106 std::cout <<
"ClapTrap " << name <<
" has " << hitPoints <<
" hit points remaining." <<
std::endl;
115 if (hitPoints > 0 && energyPoints > 0) {
116 std::cout <<
"ClapTrap " << name <<
" repairs itself, regaining " << amount <<
" hit points!" <<
std::endl;
119 std::cout <<
"ClapTrap " << name <<
" now has " << hitPoints <<
" hit points and " << energyPoints
121 }
else if (hitPoints == 0) {
122 std::cout <<
"ClapTrap " << name <<
" cannot be repaired as it has no hit points!" <<
std::endl;
124 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.