Files
cpp01/ex03/HumanB/HumanB.cpp
2025-09-14 13:52:18 +02:00

35 lines
1.2 KiB
C++

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* HumanB.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/06 02:27:27 by aortigos #+# #+# */
/* Updated: 2025/09/06 02:28:09 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "HumanB.hpp"
HumanB::HumanB(const std::string &name)
: name(name), weapon(NULL) {}
void HumanB::attack() const
{
if (weapon)
{
std::cout << this->name << " attacks with their "
<< this->weapon->getType()
<< std::endl;
} else {
std::cout << this->name << " has no weapon"
<< std::endl;
}
}
void HumanB::setWeapon(Weapon &w)
{
this->weapon = &w;
}