fix: ex03
This commit is contained in:
@ -4,18 +4,10 @@
|
||||
#include <string>
|
||||
|
||||
HumanB::HumanB(const std::string& name)
|
||||
{
|
||||
this->_name = name;
|
||||
}
|
||||
|
||||
HumanB::HumanB()
|
||||
{
|
||||
std::cout << "HumanB()" << std::endl;
|
||||
}
|
||||
|
||||
HumanB::HumanB(const HumanB& src)
|
||||
{
|
||||
*this = src;
|
||||
this->_name = name;
|
||||
this->_weapon = NULL;
|
||||
}
|
||||
|
||||
HumanB::~HumanB()
|
||||
@ -23,21 +15,19 @@ HumanB::~HumanB()
|
||||
std::cout << "~HumanB()" << std::endl;
|
||||
}
|
||||
|
||||
HumanB& HumanB::operator=(const HumanB& src)
|
||||
{
|
||||
this->_weapon = src._weapon;
|
||||
this->_name = src._name;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void HumanB::attack()
|
||||
{
|
||||
std::cout << this->_name << " attacks with their " << this->_weapon.getType() << std::endl;
|
||||
std::cout << this->_name << " attacks with their ";
|
||||
if (this->_weapon == NULL)
|
||||
std::cout << "hands";
|
||||
else
|
||||
std::cout << this->_weapon->getType();
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
void HumanB::setWeapon(const Weapon &weapon)
|
||||
{
|
||||
this->_weapon = weapon;
|
||||
this->_weapon = &weapon;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user