HumanB.cpp
1 /* ************************************************************************** */ 2 /* */ 3 /* ::: :::::::: */ 4 /* HumanB.cpp :+: :+: :+: */ 5 /* +:+ +:+ +:+ */ 6 /* By: gychoi <gychoi@student.42seoul.kr> +#+ +:+ +#+ */ 7 /* +#+#+#+#+#+ +#+ */ 8 /* Created: 2023/07/25 21:20:28 by gychoi #+# #+# */ 9 /* Updated: 2023/07/25 22:24:09 by gychoi ### ########.fr */ 10 /* */ 11 /* ************************************************************************** */ 12 13 #include "HumanB.hpp" 14 15 HumanB::HumanB(const std::string& name) : _weapon(0), _name(name) {} 16 17 void HumanB::setWeapon(Weapon& weapon) 18 { 19 _weapon = &weapon; 20 } 21 22 void HumanB::attack(void) 23 { 24 if (_weapon) 25 std::cout << _name << " attacks with their " << _weapon->getType() << std::endl; 26 else 27 std::cout << _name << " sadly perished without a weapon" << std::endl; 28 }