recration of ex03
This commit is contained in:
@ -1,29 +1,43 @@
|
||||
#include "HumanB.hpp"
|
||||
#include "Weapon.hpp"
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
HumanB::HumanB(std::string name)
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
HumanB::HumanB(const std::string& name)
|
||||
{
|
||||
this->weapon = NULL;
|
||||
this->name = name;
|
||||
this->_name = name;
|
||||
}
|
||||
|
||||
HumanB::HumanB()
|
||||
{
|
||||
std::cout << "HumanB()" << std::endl;
|
||||
}
|
||||
|
||||
HumanB::HumanB(const HumanB& src)
|
||||
{
|
||||
*this = src;
|
||||
}
|
||||
|
||||
HumanB::~HumanB()
|
||||
{}
|
||||
|
||||
void HumanB::attack()
|
||||
{
|
||||
if (this->weapon == NULL)
|
||||
{
|
||||
std::cerr << this->name << " can't attack without weapon" << std::endl;
|
||||
return;
|
||||
}
|
||||
std::cout << this->name << " attacks with their " << this->weapon->getType() << std::endl;
|
||||
std::cout << "~HumanB()" << std::endl;
|
||||
}
|
||||
|
||||
void HumanB::setWeapon(Weapon& new_weapon)
|
||||
HumanB& HumanB::operator=(const HumanB& src)
|
||||
{
|
||||
this->weapon = &new_weapon;
|
||||
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;
|
||||
}
|
||||
|
||||
void HumanB::setWeapon(const Weapon &weapon)
|
||||
{
|
||||
this->_weapon = weapon;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user