d04 correction deux erreurs
This commit is contained in:
@@ -1,22 +1,18 @@
|
||||
#include "HumanB.hpp"
|
||||
|
||||
HumanB::HumanB( std::string name ) {
|
||||
|
||||
this->_name = name;
|
||||
|
||||
}
|
||||
HumanB::~HumanB() {}
|
||||
|
||||
void HumanB::setWeapon( Weapon &weapon ) {
|
||||
|
||||
this->_weapon = &weapon;
|
||||
|
||||
}
|
||||
|
||||
void HumanB::attack( void ) {
|
||||
|
||||
if (!this->_weapon)
|
||||
return;
|
||||
std::cout << this->_name << " attacks with their ";
|
||||
std::cout << this->_weapon->getType() << std::endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
#include "Weapon.hpp"
|
||||
|
||||
Weapon::Weapon( std::string type ) {
|
||||
|
||||
this->_type = type;
|
||||
return;
|
||||
|
||||
}
|
||||
Weapon::~Weapon() {}
|
||||
|
||||
std::string const & Weapon::getType( void ) const {
|
||||
|
||||
return this->_type;
|
||||
|
||||
}
|
||||
|
||||
void Weapon::setType( std::string type ) {
|
||||
|
||||
this->_type = type;
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ int main()
|
||||
{
|
||||
Weapon club = Weapon("crude spiked club");
|
||||
HumanB jim("Jim");
|
||||
jim.attack();
|
||||
jim.setWeapon(club);
|
||||
jim.attack();
|
||||
club.setType("some other type of club");
|
||||
|
||||
BIN
d01/ex03/war
Executable file
BIN
d01/ex03/war
Executable file
Binary file not shown.
Reference in New Issue
Block a user