cpp01...
This commit is contained in:
34
ex03/HumanB/HumanB.cpp
Normal file
34
ex03/HumanB/HumanB.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 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;
|
||||
}
|
||||
Reference in New Issue
Block a user