ex02 done and modified 42header on files

This commit is contained in:
2025-09-19 13:10:16 +02:00
parent 7cce8266c4
commit 5373b7728d
12 changed files with 401 additions and 4 deletions

View File

@@ -0,0 +1,57 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* FragTrap.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/06 02:27:27 by aortigos #+# #+# */
/* Updated: 2025/09/06 02:28:09 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "FragTrap.hpp"
FragTrap::FragTrap() : ClapTrap("(NULL)")
{
this->health = 100;
this->energy = 100;
this->attackDamage = 30;
std::cout << "FragTrap default constructor called " << this->name
<< std::endl;
}
FragTrap::FragTrap(std::string name) : ClapTrap(name)
{
this->health = 100;
this->energy = 100;
this->attackDamage = 30;
std::cout << "FragTrap constructor called " << this->name
<< std::endl;
}
FragTrap::FragTrap(const FragTrap &other) : ClapTrap(other) { }
FragTrap& FragTrap::operator=(const FragTrap &other)
{
if (this != &other)
{
this->name = other.name;
this->health = other.health;
this->energy = other.energy;
this->attackDamage = other.attackDamage;
}
return (*this);
}
FragTrap::~FragTrap()
{
std::cout << "FragTrap destructor called for "
<< this->name << std::endl;
}
void FragTrap::highFivesGuys(void)
{
std::cout << "FragTrap " << this->name << " has requested a high-five!"
<< std::endl;
}

View File

@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* FragTrap.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/06 02:27:27 by aortigos #+# #+# */
/* Updated: 2025/09/06 02:28:09 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FRAGTRAP_HPP
# define FRAGTRAP_HPP
# include <iostream>
# include "../ClapTrap/ClapTrab.hpp"
class FragTrap : public ClapTrap
{
public:
FragTrap();
FragTrap(std::string name);
FragTrap(const FragTrap &other);
FragTrap &operator=(const FragTrap &other);
~FragTrap();
void highFivesGuys(void);
};
#endif