From a909970d76b7ca61fb8eea5fcbe9d97af7983abe Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 10 Feb 2025 10:59:48 +0100 Subject: [PATCH] style: using the canonical form --- cpp03/ex00/ClapTrap.cpp | 19 +++++++++++++++- cpp03/ex00/ClapTrap.hpp | 8 ++++--- cpp03/ex00/ScavTrap.cpp | 49 +++++++++++++++++++++++++++++++++++++++++ cpp03/ex00/main.cpp | 13 ++++------- cpp03/ex01/ClapTrap.cpp | 15 ++++++++++++- cpp03/ex01/ClapTrap.hpp | 3 ++- cpp03/ex01/FragTrap.cpp | 0 cpp03/ex01/FragTrap.hpp | 0 cpp03/ex01/ScavTrap.cpp | 26 ++++++++++++++++++++-- cpp03/ex01/ScavTrap.hpp | 5 ++++- cpp03/ex01/main.cpp | 24 ++++++++++---------- cpp03/ex02/ClapTrap.cpp | 15 ++++++++++++- cpp03/ex02/ClapTrap.hpp | 3 ++- cpp03/ex02/FragTrap.cpp | 22 +++++++++++++++++- cpp03/ex02/FragTrap.hpp | 5 ++++- cpp03/ex02/ScavTrap.cpp | 24 +++++++++++++++++++- cpp03/ex02/ScavTrap.hpp | 5 ++++- cpp03/ex02/main.cpp | 2 +- 18 files changed, 201 insertions(+), 37 deletions(-) create mode 100644 cpp03/ex00/ScavTrap.cpp delete mode 100644 cpp03/ex01/FragTrap.cpp delete mode 100644 cpp03/ex01/FragTrap.hpp diff --git a/cpp03/ex00/ClapTrap.cpp b/cpp03/ex00/ClapTrap.cpp index dea7cfe..c931428 100644 --- a/cpp03/ex00/ClapTrap.cpp +++ b/cpp03/ex00/ClapTrap.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/10 13:59:49 by rparodi #+# #+# */ -/* Updated: 2025/01/14 21:59:42 by rparodi ### ########.fr */ +/* Updated: 2025/02/10 10:55:30 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,15 @@ #include #include +ClapTrap::ClapTrap() { + _name = ""; + _hit_point = 0; + _energy_point = 0; + _attack_damage = 0; + + std::cout << "\n[Init] ClapTrap (no_name)" << std::endl; +} + ClapTrap::ClapTrap(std::string name) { _name = name; _hit_point = 10; @@ -22,6 +31,14 @@ ClapTrap::ClapTrap(std::string name) { std::cout << "\n[Init] ClapTrap:\n\t" << "Name: " << _name << std::endl; } +ClapTrap::ClapTrap(ClapTrap const ©) { + _name = copy._name; + _hit_point = copy._hit_point; + _energy_point = copy._energy_point; + _attack_damage = copy._attack_damage; + std::cout << "\n[Init] ClapTrap (copy):\n\t" << "Name: " << _name << std::endl; +} + ClapTrap::~ClapTrap() { std::cout << "\n[Delete] ClapTrap:\n\t" << "Name: " << _name << std::endl; } diff --git a/cpp03/ex00/ClapTrap.hpp b/cpp03/ex00/ClapTrap.hpp index 5cfa268..218d95b 100644 --- a/cpp03/ex00/ClapTrap.hpp +++ b/cpp03/ex00/ClapTrap.hpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/10 14:54:21 by rparodi #+# #+# */ -/* Updated: 2025/01/10 15:52:10 by rparodi ### ########.fr */ +/* Updated: 2025/02/10 10:24:18 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,17 +17,19 @@ class ClapTrap { public: + ClapTrap(); + ClapTrap(ClapTrap const ©); ClapTrap(std::string name); ~ClapTrap(); void attack(const std::string& target); void takeDamage(unsigned int amount); void beRepaired(unsigned int amount); - private: - ClapTrap(); + protected: std::string _name; int _hit_point; int _energy_point; int _attack_damage; + private: }; diff --git a/cpp03/ex00/ScavTrap.cpp b/cpp03/ex00/ScavTrap.cpp new file mode 100644 index 0000000..dbc59b9 --- /dev/null +++ b/cpp03/ex00/ScavTrap.cpp @@ -0,0 +1,49 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ScavTrap.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/01/24 17:41:01 by rparodi #+# #+# */ +/* Updated: 2025/02/10 10:56:14 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "ScavTrap.hpp" + +ScavTrap::ScavTrap() { + _name = ""; + _hit_point = 0; + _energy_point = 0; + _attack_damage = 0; + _gateKeeperMode = false; + std::cout << "\n[Init] ScavTrap (no_name)" << std::endl; +} + +ScavTrap::ScavTrap(ScavTrap const ©) { + _name = copy._name; + _hit_point = copy._hit_point; + _energy_point = copy._energy_point; + _attack_damage = copy._attack_damage; + _gateKeeperMode = copy._gateKeeperMode; + std::cout << "\n[Init] ScavTrap (copy):\n\t" << "Name: " << _name << std::endl; +} + +ScavTrap::ScavTrap (std::string name) { + _name = name; + _hit_point = 100; + _energy_point = 50; + _attack_damage = 20; + _gateKeeperMode = false; + std::cout << "\n[Init] ScavTrap:\n\t" << "Name: " << _name << std::endl; +} + +ScavTrap::~ScavTrap() { + +} + +void ScavTrap::guardGate() { +_gateKeeperMode = !_gateKeeperMode; + std::cout << "\n[Mode] ScavTrap:\n\t" << "Name: " << _name << " the mode gate keeper is now: " << (_gateKeeperMode ? "enable" : "disable") << std::endl; +} diff --git a/cpp03/ex00/main.cpp b/cpp03/ex00/main.cpp index c61ddf4..d03673a 100644 --- a/cpp03/ex00/main.cpp +++ b/cpp03/ex00/main.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/10 15:50:07 by rparodi #+# #+# */ -/* Updated: 2025/01/14 22:04:48 by rparodi ### ########.fr */ +/* Updated: 2025/02/10 10:52:17 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,13 +14,8 @@ #include int main(void) { - std::cout << "[Broadcast]\n\tIn the Red corner the first cat of the 42 school !" << std::endl; - ClapTrap test("Norminet"); - test.attack("Moulinette"); - test.takeDamage(42); - test.beRepaired(42); - std::cout << "\n\n[Broadcast]\n\tIn the Blue corner the actual cat of the 42 school !" << std::endl; - ClapTrap test2("Moulinette"); - test2.beRepaired(32); + std::cout << "[Broadcast]\n\tIn the Blue corner the actual cat of the 42 school !" << std::endl; + ClapTrap test("Moulinette"); + test.beRepaired(32); return (0); } diff --git a/cpp03/ex01/ClapTrap.cpp b/cpp03/ex01/ClapTrap.cpp index de4937e..ee8495a 100644 --- a/cpp03/ex01/ClapTrap.cpp +++ b/cpp03/ex01/ClapTrap.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/10 13:59:49 by rparodi #+# #+# */ -/* Updated: 2025/01/24 18:32:35 by rparodi ### ########.fr */ +/* Updated: 2025/02/10 10:53:38 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,7 +15,12 @@ #include ClapTrap::ClapTrap() { + _name = ""; + _hit_point = 0; + _energy_point = 0; + _attack_damage = 0; + std::cout << "\n[Init] ClapTrap (no_name):\n\t" << "Name: " << _name << std::endl; } ClapTrap::ClapTrap(std::string name) { @@ -26,6 +31,14 @@ ClapTrap::ClapTrap(std::string name) { std::cout << "\n[Init] ClapTrap:\n\t" << "Name: " << _name << std::endl; } +ClapTrap::ClapTrap(ClapTrap const ©) { + _name = copy._name; + _hit_point = copy._hit_point; + _energy_point = copy._energy_point; + _attack_damage = copy._attack_damage; + std::cout << "\n[Init] ClapTrap (copy):\n\t" << "Name: " << _name << std::endl; +} + ClapTrap::~ClapTrap() { std::cout << "\n[Delete] ClapTrap:\n\t" << "Name: " << _name << std::endl; } diff --git a/cpp03/ex01/ClapTrap.hpp b/cpp03/ex01/ClapTrap.hpp index a6c5d7b..218d95b 100644 --- a/cpp03/ex01/ClapTrap.hpp +++ b/cpp03/ex01/ClapTrap.hpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/10 14:54:21 by rparodi #+# #+# */ -/* Updated: 2025/01/24 18:32:41 by rparodi ### ########.fr */ +/* Updated: 2025/02/10 10:24:18 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,6 +18,7 @@ class ClapTrap { public: ClapTrap(); + ClapTrap(ClapTrap const ©); ClapTrap(std::string name); ~ClapTrap(); void attack(const std::string& target); diff --git a/cpp03/ex01/FragTrap.cpp b/cpp03/ex01/FragTrap.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/cpp03/ex01/FragTrap.hpp b/cpp03/ex01/FragTrap.hpp deleted file mode 100644 index e69de29..0000000 diff --git a/cpp03/ex01/ScavTrap.cpp b/cpp03/ex01/ScavTrap.cpp index 13c6c83..dbc59b9 100644 --- a/cpp03/ex01/ScavTrap.cpp +++ b/cpp03/ex01/ScavTrap.cpp @@ -6,12 +6,30 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/24 17:41:01 by rparodi #+# #+# */ -/* Updated: 2025/01/24 20:31:45 by rparodi ### ########.fr */ +/* Updated: 2025/02/10 10:56:14 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "ScavTrap.hpp" +ScavTrap::ScavTrap() { + _name = ""; + _hit_point = 0; + _energy_point = 0; + _attack_damage = 0; + _gateKeeperMode = false; + std::cout << "\n[Init] ScavTrap (no_name)" << std::endl; +} + +ScavTrap::ScavTrap(ScavTrap const ©) { + _name = copy._name; + _hit_point = copy._hit_point; + _energy_point = copy._energy_point; + _attack_damage = copy._attack_damage; + _gateKeeperMode = copy._gateKeeperMode; + std::cout << "\n[Init] ScavTrap (copy):\n\t" << "Name: " << _name << std::endl; +} + ScavTrap::ScavTrap (std::string name) { _name = name; _hit_point = 100; @@ -21,7 +39,11 @@ ScavTrap::ScavTrap (std::string name) { std::cout << "\n[Init] ScavTrap:\n\t" << "Name: " << _name << std::endl; } +ScavTrap::~ScavTrap() { + +} + void ScavTrap::guardGate() { - _gateKeeperMode = !_gateKeeperMode; +_gateKeeperMode = !_gateKeeperMode; std::cout << "\n[Mode] ScavTrap:\n\t" << "Name: " << _name << " the mode gate keeper is now: " << (_gateKeeperMode ? "enable" : "disable") << std::endl; } diff --git a/cpp03/ex01/ScavTrap.hpp b/cpp03/ex01/ScavTrap.hpp index 2377c84..fbf5457 100644 --- a/cpp03/ex01/ScavTrap.hpp +++ b/cpp03/ex01/ScavTrap.hpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/20 23:13:16 by rparodi #+# #+# */ -/* Updated: 2025/01/24 18:46:42 by rparodi ### ########.fr */ +/* Updated: 2025/02/10 10:43:14 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,10 @@ class ScavTrap : public ClapTrap { public: + ScavTrap(); + ScavTrap(ScavTrap const ©); ScavTrap(std::string name); + ~ScavTrap(); void guardGate(); protected: diff --git a/cpp03/ex01/main.cpp b/cpp03/ex01/main.cpp index ac67232..0361439 100644 --- a/cpp03/ex01/main.cpp +++ b/cpp03/ex01/main.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/10 15:50:07 by rparodi #+# #+# */ -/* Updated: 2025/01/24 18:51:51 by rparodi ### ########.fr */ +/* Updated: 2025/02/10 10:52:36 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,16 +15,16 @@ #include int main(void) { - std::cout << "[Broadcast]\n\tIn the Red corner the first cat of the 42 school !" << std::endl; - ScavTrap test("Norminet"); - test.attack("Moulinette"); - test.takeDamage(42); - test.beRepaired(42); - test.guardGate(); - test.guardGate(); - test.guardGate(); - std::cout << "\n\n[Broadcast]\n\tIn the Blue corner the actual cat of the 42 school !" << std::endl; - ClapTrap test2("Moulinette"); - test2.beRepaired(32); + std::cout << "[Broadcast]\n\tIn the Blue corner the actual cat of the 42 school !" << std::endl; + ClapTrap test("Moulinette"); + test.beRepaired(32); + std::cout << "\n\n[Broadcast]\n\tIn the Red corner the first cat of the 42 school !" << std::endl; + ScavTrap test2("Norminet"); + test2.attack("Moulinette"); + test2.takeDamage(42); + test2.beRepaired(42); + test2.guardGate(); + test2.guardGate(); + test2.guardGate(); return (0); } diff --git a/cpp03/ex02/ClapTrap.cpp b/cpp03/ex02/ClapTrap.cpp index de4937e..c931428 100644 --- a/cpp03/ex02/ClapTrap.cpp +++ b/cpp03/ex02/ClapTrap.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/10 13:59:49 by rparodi #+# #+# */ -/* Updated: 2025/01/24 18:32:35 by rparodi ### ########.fr */ +/* Updated: 2025/02/10 10:55:30 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,7 +15,12 @@ #include ClapTrap::ClapTrap() { + _name = ""; + _hit_point = 0; + _energy_point = 0; + _attack_damage = 0; + std::cout << "\n[Init] ClapTrap (no_name)" << std::endl; } ClapTrap::ClapTrap(std::string name) { @@ -26,6 +31,14 @@ ClapTrap::ClapTrap(std::string name) { std::cout << "\n[Init] ClapTrap:\n\t" << "Name: " << _name << std::endl; } +ClapTrap::ClapTrap(ClapTrap const ©) { + _name = copy._name; + _hit_point = copy._hit_point; + _energy_point = copy._energy_point; + _attack_damage = copy._attack_damage; + std::cout << "\n[Init] ClapTrap (copy):\n\t" << "Name: " << _name << std::endl; +} + ClapTrap::~ClapTrap() { std::cout << "\n[Delete] ClapTrap:\n\t" << "Name: " << _name << std::endl; } diff --git a/cpp03/ex02/ClapTrap.hpp b/cpp03/ex02/ClapTrap.hpp index a6c5d7b..218d95b 100644 --- a/cpp03/ex02/ClapTrap.hpp +++ b/cpp03/ex02/ClapTrap.hpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/10 14:54:21 by rparodi #+# #+# */ -/* Updated: 2025/01/24 18:32:41 by rparodi ### ########.fr */ +/* Updated: 2025/02/10 10:24:18 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,6 +18,7 @@ class ClapTrap { public: ClapTrap(); + ClapTrap(ClapTrap const ©); ClapTrap(std::string name); ~ClapTrap(); void attack(const std::string& target); diff --git a/cpp03/ex02/FragTrap.cpp b/cpp03/ex02/FragTrap.cpp index 278d036..4b3f52f 100644 --- a/cpp03/ex02/FragTrap.cpp +++ b/cpp03/ex02/FragTrap.cpp @@ -6,12 +6,20 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/24 17:41:01 by rparodi #+# #+# */ -/* Updated: 2025/01/28 14:02:17 by rparodi ### ########.fr */ +/* Updated: 2025/02/10 10:55:37 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "FragTrap.hpp" +FragTrap::FragTrap() { + _name = ""; + _hit_point = 0; + _energy_point = 0; + _attack_damage = 0; + std::cout << "\n[Init] FragTrap (no_name)" << std::endl; +} + FragTrap::FragTrap (std::string name) { _name = name; _hit_point = 100; @@ -20,6 +28,18 @@ FragTrap::FragTrap (std::string name) { std::cout << "\n[Init] FragTrap:\n\t" << "Name: " << _name << std::endl; } +FragTrap::FragTrap(FragTrap const ©) { + _name = copy._name; + _hit_point = copy._hit_point; + _energy_point = copy._energy_point; + _attack_damage = copy._attack_damage; + std::cout << "\n[Init] FragTrap (copy):\n\t" << "Name: " << _name << std::endl; +} + +FragTrap::~FragTrap() { + +} + void FragTrap::highFivesGuys() { std::cout << "\n[Clap] FragTrap:\n\t" << "Name:" << _name << " Hey bro can i get an high five ? Thanks u brother !" << _name << "Hey bro can i get an high five ? Thanks u brother !" << std::endl; } diff --git a/cpp03/ex02/FragTrap.hpp b/cpp03/ex02/FragTrap.hpp index 4d66b0a..b7a5f8c 100644 --- a/cpp03/ex02/FragTrap.hpp +++ b/cpp03/ex02/FragTrap.hpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/20 23:13:16 by rparodi #+# #+# */ -/* Updated: 2025/01/24 20:54:17 by rparodi ### ########.fr */ +/* Updated: 2025/02/10 10:28:51 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,10 @@ class FragTrap: public ClapTrap { public: + FragTrap(); + FragTrap(FragTrap const ©); FragTrap(std::string name); + ~FragTrap(); void highFivesGuys(void); protected: diff --git a/cpp03/ex02/ScavTrap.cpp b/cpp03/ex02/ScavTrap.cpp index 1696b88..dbc59b9 100644 --- a/cpp03/ex02/ScavTrap.cpp +++ b/cpp03/ex02/ScavTrap.cpp @@ -6,12 +6,30 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/24 17:41:01 by rparodi #+# #+# */ -/* Updated: 2025/01/24 19:24:05 by rparodi ### ########.fr */ +/* Updated: 2025/02/10 10:56:14 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "ScavTrap.hpp" +ScavTrap::ScavTrap() { + _name = ""; + _hit_point = 0; + _energy_point = 0; + _attack_damage = 0; + _gateKeeperMode = false; + std::cout << "\n[Init] ScavTrap (no_name)" << std::endl; +} + +ScavTrap::ScavTrap(ScavTrap const ©) { + _name = copy._name; + _hit_point = copy._hit_point; + _energy_point = copy._energy_point; + _attack_damage = copy._attack_damage; + _gateKeeperMode = copy._gateKeeperMode; + std::cout << "\n[Init] ScavTrap (copy):\n\t" << "Name: " << _name << std::endl; +} + ScavTrap::ScavTrap (std::string name) { _name = name; _hit_point = 100; @@ -21,6 +39,10 @@ ScavTrap::ScavTrap (std::string name) { std::cout << "\n[Init] ScavTrap:\n\t" << "Name: " << _name << std::endl; } +ScavTrap::~ScavTrap() { + +} + void ScavTrap::guardGate() { _gateKeeperMode = !_gateKeeperMode; std::cout << "\n[Mode] ScavTrap:\n\t" << "Name: " << _name << " the mode gate keeper is now: " << (_gateKeeperMode ? "enable" : "disable") << std::endl; diff --git a/cpp03/ex02/ScavTrap.hpp b/cpp03/ex02/ScavTrap.hpp index b8c8b8b..fbf5457 100644 --- a/cpp03/ex02/ScavTrap.hpp +++ b/cpp03/ex02/ScavTrap.hpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/20 23:13:16 by rparodi #+# #+# */ -/* Updated: 2025/01/24 20:57:35 by rparodi ### ########.fr */ +/* Updated: 2025/02/10 10:43:14 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,10 @@ class ScavTrap : public ClapTrap { public: + ScavTrap(); + ScavTrap(ScavTrap const ©); ScavTrap(std::string name); + ~ScavTrap(); void guardGate(); protected: diff --git a/cpp03/ex02/main.cpp b/cpp03/ex02/main.cpp index f83c07e..454926d 100644 --- a/cpp03/ex02/main.cpp +++ b/cpp03/ex02/main.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/10 15:50:07 by rparodi #+# #+# */ -/* Updated: 2025/01/24 21:02:23 by rparodi ### ########.fr */ +/* Updated: 2025/02/10 10:57:33 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */