diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-11-09 11:26:50 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-11-09 11:26:50 +0100 |
| commit | b799c007a1b6911fcbe5141429ea541e1277ebdd (patch) | |
| tree | d70ad0826ad2fc2d635adf9afecf89af0838d20b /cpp01/ex06 | |
| parent | 1e9d90bdf9ef5fc05093d3449d883597c7f896de (diff) | |
| download | piscine_cpp-b799c007a1b6911fcbe5141429ea541e1277ebdd.tar.gz piscine_cpp-b799c007a1b6911fcbe5141429ea541e1277ebdd.tar.bz2 piscine_cpp-b799c007a1b6911fcbe5141429ea541e1277ebdd.zip | |
Fixing some edge cases in cpp00 and cpp01, Updated formatting
Diffstat (limited to 'cpp01/ex06')
| -rw-r--r-- | cpp01/ex06/HumanA.cpp | 7 | ||||
| -rw-r--r-- | cpp01/ex06/HumanA.hpp | 6 | ||||
| -rw-r--r-- | cpp01/ex06/HumanB.cpp | 12 | ||||
| -rw-r--r-- | cpp01/ex06/HumanB.hpp | 6 | ||||
| -rw-r--r-- | cpp01/ex06/Weapon.cpp | 11 | ||||
| -rw-r--r-- | cpp01/ex06/Weapon.hpp | 8 | ||||
| -rw-r--r-- | cpp01/ex06/main.cpp | 2 |
7 files changed, 25 insertions, 27 deletions
diff --git a/cpp01/ex06/HumanA.cpp b/cpp01/ex06/HumanA.cpp index 7e52494..ab4e5f3 100644 --- a/cpp01/ex06/HumanA.cpp +++ b/cpp01/ex06/HumanA.cpp @@ -6,16 +6,15 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/02 16:44:03 by cacharle #+# #+# */ -/* Updated: 2020/04/13 10:26:03 by charles ### ########.fr */ +/* Updated: 2020/11/09 11:09:22 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include "HumanA.hpp" -HumanA::HumanA(std::string name, Weapon& weapon) +HumanA::HumanA(std::string const& name, Weapon& weapon) : m_name(name), m_weapon(weapon) -{ -} +{} void HumanA::attack() { diff --git a/cpp01/ex06/HumanA.hpp b/cpp01/ex06/HumanA.hpp index f1691b3..d05d2fd 100644 --- a/cpp01/ex06/HumanA.hpp +++ b/cpp01/ex06/HumanA.hpp @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/02 16:37:23 by cacharle #+# #+# */ -/* Updated: 2020/04/13 10:24:13 by charles ### ########.fr */ +/* Updated: 2020/11/09 11:08:55 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,11 +19,11 @@ class HumanA { public: - HumanA(std::string name, Weapon& weapon); + HumanA(std::string const& name, Weapon& weapon); void attack(); private: std::string m_name; - Weapon& m_weapon; + Weapon& m_weapon; }; #endif diff --git a/cpp01/ex06/HumanB.cpp b/cpp01/ex06/HumanB.cpp index 98774aa..e6adb22 100644 --- a/cpp01/ex06/HumanB.cpp +++ b/cpp01/ex06/HumanB.cpp @@ -6,20 +6,22 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/02 16:46:02 by cacharle #+# #+# */ -/* Updated: 2020/04/13 10:25:54 by charles ### ########.fr */ +/* Updated: 2020/11/09 11:13:34 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include "HumanB.hpp" -HumanB::HumanB(std::string name) +HumanB::HumanB(std::string const& name) : m_name(name), m_weapon(NULL) -{ -} +{} void HumanB::attack() { - std::cout << m_name << " attack with his " << m_weapon->getType() << std::endl; + if (m_weapon == NULL) + std::cout << m_name << " doesn't have any weapon " << std::endl; + else + std::cout << m_name << " attack with his " << m_weapon->getType() << std::endl; } void HumanB::setWeapon(Weapon& weapon) diff --git a/cpp01/ex06/HumanB.hpp b/cpp01/ex06/HumanB.hpp index 269f4fc..fc9236c 100644 --- a/cpp01/ex06/HumanB.hpp +++ b/cpp01/ex06/HumanB.hpp @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/02 16:42:54 by cacharle #+# #+# */ -/* Updated: 2020/04/13 10:23:31 by charles ### ########.fr */ +/* Updated: 2020/11/09 11:09:56 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,12 +19,12 @@ class HumanB { public: - HumanB(std::string name); + HumanB(std::string const& name); void attack(); void setWeapon(Weapon& weapon); private: std::string m_name; - Weapon* m_weapon; + Weapon* m_weapon; }; #endif diff --git a/cpp01/ex06/Weapon.cpp b/cpp01/ex06/Weapon.cpp index e517947..88b4357 100644 --- a/cpp01/ex06/Weapon.cpp +++ b/cpp01/ex06/Weapon.cpp @@ -6,23 +6,20 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/02 16:36:23 by cacharle #+# #+# */ -/* Updated: 2020/04/13 10:25:35 by charles ### ########.fr */ +/* Updated: 2020/11/09 11:08:23 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include "Weapon.hpp" -Weapon::Weapon(std::string t) - : type(t) -{ -} +Weapon::Weapon(std::string t) : type(t) {} -const std::string& Weapon::getType() const +std::string const& Weapon::getType() const { return type; } -void Weapon::setType(const std::string& t) +void Weapon::setType(std::string const& t) { type = t; } diff --git a/cpp01/ex06/Weapon.hpp b/cpp01/ex06/Weapon.hpp index d9ad476..08fef0c 100644 --- a/cpp01/ex06/Weapon.hpp +++ b/cpp01/ex06/Weapon.hpp @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/02 16:34:31 by cacharle #+# #+# */ -/* Updated: 2020/04/13 10:16:46 by charles ### ########.fr */ +/* Updated: 2020/11/09 11:08:36 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,11 +19,11 @@ class Weapon { public: Weapon(std::string t); - const std::string& getType() const; - void setType(const std::string& t); + std::string const& getType() const; + void setType(std::string const& t); private: - std::string type; // subject want litteraly `type` + std::string type; // subject wants litteraly `type` }; #endif diff --git a/cpp01/ex06/main.cpp b/cpp01/ex06/main.cpp index dfc03a0..5c92b43 100644 --- a/cpp01/ex06/main.cpp +++ b/cpp01/ex06/main.cpp @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/02 16:40:20 by cacharle #+# #+# */ -/* Updated: 2020/02/02 16:40:51 by cacharle ### ########.fr */ +/* Updated: 2020/11/09 11:13:54 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ |
