end ex03
This commit is contained in:
parent
87e67b4e79
commit
e81653bf5d
@ -6,16 +6,15 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/06/10 21:20:34 by apommier #+# #+# */
|
/* Created: 2022/06/10 21:20:34 by apommier #+# #+# */
|
||||||
/* Updated: 2022/06/16 23:41:51 by apommier ### ########.fr */
|
/* Updated: 2022/06/19 12:36:43 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "HumanA.hpp"
|
#include "HumanA.hpp"
|
||||||
|
|
||||||
HumanA::HumanA(const std::string name, Weapon Weapon)
|
HumanA::HumanA(const std::string name, Weapon &Weapon): _Weapon(Weapon)
|
||||||
{
|
{
|
||||||
this->_name = name;
|
this->_name = name;
|
||||||
this->_Weapon = &Weapon.getType();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HumanA::~HumanA(void)
|
HumanA::~HumanA(void)
|
||||||
@ -25,5 +24,5 @@ HumanA::~HumanA(void)
|
|||||||
|
|
||||||
void HumanA::attack(void)
|
void HumanA::attack(void)
|
||||||
{
|
{
|
||||||
std::cout << this->_name << " attacks with their " << this->_Weapon << std::endl;
|
std::cout << this->_name << " attacks with their " << this->_Weapon.getType() << std::endl;
|
||||||
}
|
}
|
||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/06/10 21:20:32 by apommier #+# #+# */
|
/* Created: 2022/06/10 21:20:32 by apommier #+# #+# */
|
||||||
/* Updated: 2022/06/16 23:39:42 by apommier ### ########.fr */
|
/* Updated: 2022/06/19 12:22:11 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -20,14 +20,14 @@ class HumanA {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
HumanA(const std::string name, Weapon Weapon);
|
HumanA(const std::string name, Weapon &Weapon);
|
||||||
~HumanA(void);
|
~HumanA(void);
|
||||||
void attack(void);
|
void attack(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string _name;
|
std::string _name;
|
||||||
std::string *_Weapon;
|
Weapon &_Weapon;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -6,36 +6,31 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/06/10 21:25:58 by apommier #+# #+# */
|
/* Created: 2022/06/10 21:25:58 by apommier #+# #+# */
|
||||||
/* Updated: 2022/06/16 23:42:41 by apommier ### ########.fr */
|
/* Updated: 2022/06/19 16:08:30 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "HumanB.hpp"
|
#include "HumanB.hpp"
|
||||||
|
|
||||||
|
HumanB::HumanB(std::string name) : _name(name), _Weapon(NULL)
|
||||||
HumanB::HumanB(const std::string name)
|
|
||||||
{
|
{
|
||||||
this->_name = name;
|
|
||||||
//this->_Weapon = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HumanB::HumanB(const std::string name, Weapon Weapon)
|
HumanB::HumanB(const std::string name, Weapon Weapon)
|
||||||
{
|
{
|
||||||
this->_name = name;
|
this->_name = name;
|
||||||
this->_Weapon = Weapon.getType();
|
this->_Weapon = &Weapon;
|
||||||
}
|
}
|
||||||
|
|
||||||
HumanB::~HumanB(void)
|
HumanB::~HumanB(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HumanB::setWeapon(Weapon Weapon)
|
void HumanB::setWeapon(Weapon &newWeapon) {
|
||||||
{
|
_Weapon = &newWeapon;
|
||||||
this->_Weapon = Weapon.getType();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HumanB::attack(void) const
|
void HumanB::attack(void) const
|
||||||
{
|
{
|
||||||
std::cout << this->_name << " attacks with their " << this->_Weapon << std::endl;
|
std::cout << this->_name << " attacks with their " << this->_Weapon->getType() << std::endl;
|
||||||
}
|
}
|
||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/06/10 21:23:58 by apommier #+# #+# */
|
/* Created: 2022/06/10 21:23:58 by apommier #+# #+# */
|
||||||
/* Updated: 2022/06/16 23:32:27 by apommier ### ########.fr */
|
/* Updated: 2022/06/19 16:07:36 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -19,16 +19,16 @@ class HumanB {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
HumanB(std::string name);
|
||||||
HumanB(const std::string name, Weapon Weapon);
|
HumanB(const std::string name, Weapon Weapon);
|
||||||
HumanB (const std::string name);
|
|
||||||
~HumanB(void);
|
~HumanB(void);
|
||||||
void attack(void) const;
|
void attack(void) const;
|
||||||
void setWeapon(Weapon Weapon);
|
void setWeapon(Weapon &newWeapon);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string _name;
|
std::string _name;
|
||||||
std::string &_Weapon;
|
Weapon *_Weapon;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -6,27 +6,41 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/06/10 21:13:13 by apommier #+# #+# */
|
/* Created: 2022/06/10 21:13:13 by apommier #+# #+# */
|
||||||
/* Updated: 2022/06/16 22:25:56 by apommier ### ########.fr */
|
/* Updated: 2022/06/19 15:54:48 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "Weapon.hpp"
|
#include "Weapon.hpp"
|
||||||
|
|
||||||
|
|
||||||
Weapon::Weapon(std::string name): _type(name) {
|
Weapon::Weapon() : _type("words"){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Weapon::Weapon(std::string type) : _type(type){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Weapon::~Weapon() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*Weapon::Weapon(std::string name): _type(name) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Weapon::~Weapon() {
|
Weapon::~Weapon() {
|
||||||
|
|
||||||
}
|
}*/
|
||||||
|
|
||||||
const std::string &getType(void)
|
const std::string& Weapon::getType(void) const
|
||||||
{
|
{
|
||||||
return (this->_type);
|
return (this->_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setType(const std::string &type)
|
/*void Weapon::setType(const std::string type)
|
||||||
{
|
{
|
||||||
this->_type = type;
|
this->_type = type;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
void Weapon::setType(std::string newType) {
|
||||||
|
_type = newType;
|
||||||
}
|
}
|
||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/06/10 19:43:13 by apommier #+# #+# */
|
/* Created: 2022/06/10 19:43:13 by apommier #+# #+# */
|
||||||
/* Updated: 2022/06/16 23:39:20 by apommier ### ########.fr */
|
/* Updated: 2022/06/19 15:55:10 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -21,10 +21,12 @@ class Weapon {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Weapon(std::string str);
|
Weapon();
|
||||||
~Weapon(void);
|
Weapon(std::string type);
|
||||||
std::string& getType(void);
|
~Weapon();
|
||||||
void setType(const std::string type);
|
const std::string& getType( void ) const;
|
||||||
|
//void setType(const std::string type);
|
||||||
|
void setType(std::string newType);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user