From 51f2946231bf6b8eeeb1a104dd666134a2612fe2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 14 Jan 2025 22:05:48 +0100 Subject: [PATCH] style: adding the boradcast and the moulinette character --- cpp03/ex00/ClapTrap.cpp | 12 ++++++------ cpp03/ex00/main.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cpp03/ex00/ClapTrap.cpp b/cpp03/ex00/ClapTrap.cpp index cb1e3f3..dea7cfe 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/13 14:58:53 by rparodi ### ########.fr */ +/* Updated: 2025/01/14 21:59:42 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,12 +27,12 @@ ClapTrap::~ClapTrap() { } void ClapTrap::attack(const std::string& target) { - if (_energy_point <= 0 && _hit_point <= 0) { - std::cerr << "Not enough energy to attack" << std::endl; + if (_energy_point <= 0 || _hit_point <= 0) { + std::cerr << "\n[Attack] ClapTrap:\n\t" << "Not enough energy to attack" << std::endl; return ; } _energy_point--; - std::cout << "[Attack] ClapTrap:\n\t" << _name << " attacks " << target << ", causing " << _attack_damage << " points of damage!" << std::endl; + std::cout << "\n[Attack] ClapTrap:\n\t" << _name << " attacks " << target << ", causing " << _attack_damage << " points of damage!" << std::endl; } void ClapTrap::takeDamage(unsigned int amount) { @@ -41,8 +41,8 @@ void ClapTrap::takeDamage(unsigned int amount) { } void ClapTrap::beRepaired(unsigned int amount) { - if (_energy_point <= 0 && _hit_point <= 0) { - std::cerr << "Not enough energy to repair" << std::endl; + if (_energy_point <= 0 || _hit_point <= 0) { + std::cerr << "\n[Repair] ClapTrap:\n\t" << "Not enough energy to repair" << std::endl; return ; } _energy_point--; diff --git a/cpp03/ex00/main.cpp b/cpp03/ex00/main.cpp index 07536c4..c61ddf4 100644 --- a/cpp03/ex00/main.cpp +++ b/cpp03/ex00/main.cpp @@ -6,16 +6,21 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/10 15:50:07 by rparodi #+# #+# */ -/* Updated: 2025/01/10 15:57:10 by rparodi ### ########.fr */ +/* Updated: 2025/01/14 22:04:48 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "ClapTrap.hpp" +#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); return (0); }