ex02 done and modified 42header on files
This commit is contained in:
57
ex02/FragTrap/FragTrap.cpp
Normal file
57
ex02/FragTrap/FragTrap.cpp
Normal 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;
|
||||
}
|
||||
32
ex02/FragTrap/FragTrap.hpp
Normal file
32
ex02/FragTrap/FragTrap.hpp
Normal 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
|
||||
Reference in New Issue
Block a user