init: ex03

This commit is contained in:
Camille Chauvet
2023-05-24 14:41:02 +00:00
parent e67f872720
commit f063902349
8 changed files with 174 additions and 0 deletions

29
ex03/src/HumanB.cpp Normal file
View File

@ -0,0 +1,29 @@
#include "HumanB.hpp"
#include "Weapon.hpp"
#include <cstddef>
#include <string>
#include <iostream>
HumanB::HumanB(std::string name)
{
this->weapon = NULL;
this->name = name;
}
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;
}
void HumanB::setWeapon(Weapon& new_weapon)
{
this->weapon = &new_weapon;
}