Message when repair ClapTrap
This commit is contained in:
@@ -22,7 +22,10 @@ ClapTrap::ClapTrap() :
|
||||
ClapTrap::ClapTrap(std::string name) :
|
||||
name(name), health(10),
|
||||
energy(10), attackDamage(0)
|
||||
{}
|
||||
{
|
||||
std::cout << "Default constructor called for "
|
||||
<< name << std::endl;
|
||||
}
|
||||
|
||||
ClapTrap::ClapTrap(const ClapTrap &target)
|
||||
{
|
||||
@@ -46,7 +49,8 @@ ClapTrap& ClapTrap::operator=(const ClapTrap &target)
|
||||
|
||||
ClapTrap::~ClapTrap()
|
||||
{
|
||||
std::cout << "Destructor called" << std::endl;
|
||||
std::cout << "Destructor called for "
|
||||
<< this->name << std::endl;
|
||||
}
|
||||
|
||||
void ClapTrap::attack(const std::string &target)
|
||||
@@ -70,13 +74,20 @@ void ClapTrap::takeDamage(unsigned int amount)
|
||||
std::cout << "ClapTrap " << this->name
|
||||
<< " recieves " << amount
|
||||
<< " points of damage!" << std::endl;
|
||||
this->health -= amount;
|
||||
if (amount >= this->health)
|
||||
this->health = 0;
|
||||
else
|
||||
this->health -= amount;
|
||||
}
|
||||
|
||||
void ClapTrap::beRepaired(unsigned int amount)
|
||||
{
|
||||
if (this->energy > 0)
|
||||
{
|
||||
std::cout << "ClapTrap " << this->name
|
||||
<< " repairs itself, recovering " << amount
|
||||
<< " hit points!" << std::endl;
|
||||
|
||||
this->health += amount;
|
||||
this->energy -= 1;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user