init: ex03
This commit is contained in:
29
ex03/src/HumanB.cpp
Normal file
29
ex03/src/HumanB.cpp
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user