Min fixes v2.0

This commit is contained in:
Angel Ortigosa Perez
2025-10-26 20:32:36 +01:00
parent 46b7b99abb
commit c9e9e69c06
3 changed files with 21 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
NAME = fragtrap
SRCS = main.cpp ClapTrap/ClapTrap.cpp ScavTrap/ScavTrap.cpp
SRCS = main.cpp ClapTrap/ClapTrap.cpp ScavTrap/ScavTrap.cpp FragTrap/FragTrap.cpp
OBJS=$(SRCS:.cpp=.o)
CC=c++

View File

@@ -30,7 +30,17 @@ ScavTrap::ScavTrap(std::string name) : ClapTrap(name)
<< std::endl;
}
ScavTrap::ScavTrap(const ScavTrap &other) : ClapTrap(other) { }
ScavTrap::ScavTrap(const ScavTrap &other) : ClapTrap(other)
{
this->name = other.name;
this->health = other.health;
this->energy = other.energy;
this->attackDamage = other.attackDamage;
std::cout << "ScavTrap copy constructor called for " << this->name << std::endl;
}
ScavTrap& ScavTrap::operator=(const ScavTrap &other)
{

View File

@@ -6,12 +6,13 @@
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/12 13:17:34 by aortigos #+# #+# */
/* Updated: 2025/09/19 12:34:26 by aortigos ### ########.fr */
/* Updated: 2025/10/26 20:25:35 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "ClapTrap/ClapTrap.hpp"
#include "ScavTrap/ScavTrap.hpp"
#include "FragTrap/FragTrap.hpp"
int main()
{
@@ -29,11 +30,13 @@ int main()
b.beRepaired(10);
b.guardGate();
std::cout << "\n--- Copy and Assignment Test ---" << std::endl;
ScavTrap c = b; // copy constructor
ScavTrap d;
d = b; // assignment operator
d.attack("another enemy");
std::cout << "\n--- Testing FragTrap ---" << std::endl;
FragTrap c("Bob");
c.attack("enemy");
c.takeDamage(20);
c.beRepaired(10);
c.highFivesGuys();
return 0;
}