feat: finishing the exercice 02 & 03 from the module 01

This commit is contained in:
Raphael 2024-11-05 14:50:42 +01:00
parent a6ec8890cf
commit 2b197d8d05
11 changed files with 364 additions and 68 deletions

37
cpp01/ex03/HumanB.cpp Normal file
View file

@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* HumanB.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/05 13:34:23 by rparodi #+# #+# */
/* Updated: 2024/11/05 14:46:40 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "HumanB.hpp"
HumanB::HumanB(std::string name)
{
_name = name;
_isArmed = false;
_weaponGiven = NULL;
}
HumanB::~HumanB()
{
}
void HumanB::setWeapon(Weapon &_toGive)
{
_isArmed = true;
_weaponGiven = &_toGive;
}
void HumanB::attack()
{
if (_isArmed == true)
std::cout << CLR_GOLD << _name << CLR_YELLOW << " attacks with their " << CLR_GOLD << _weaponGiven->getType() << CLR_RESET << std::endl;
}