Min fixes v2.0
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
NAME = fragtrap
|
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)
|
OBJS=$(SRCS:.cpp=.o)
|
||||||
|
|
||||||
CC=c++
|
CC=c++
|
||||||
|
|||||||
@@ -30,7 +30,17 @@ ScavTrap::ScavTrap(std::string name) : ClapTrap(name)
|
|||||||
<< std::endl;
|
<< 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)
|
ScavTrap& ScavTrap::operator=(const ScavTrap &other)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,12 +6,13 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/09/12 13:17:34 by aortigos #+# #+# */
|
/* 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 "ClapTrap/ClapTrap.hpp"
|
||||||
#include "ScavTrap/ScavTrap.hpp"
|
#include "ScavTrap/ScavTrap.hpp"
|
||||||
|
#include "FragTrap/FragTrap.hpp"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -29,11 +30,13 @@ int main()
|
|||||||
b.beRepaired(10);
|
b.beRepaired(10);
|
||||||
b.guardGate();
|
b.guardGate();
|
||||||
|
|
||||||
std::cout << "\n--- Copy and Assignment Test ---" << std::endl;
|
std::cout << "\n--- Testing FragTrap ---" << std::endl;
|
||||||
ScavTrap c = b; // copy constructor
|
FragTrap c("Bob");
|
||||||
ScavTrap d;
|
c.attack("enemy");
|
||||||
d = b; // assignment operator
|
c.takeDamage(20);
|
||||||
d.attack("another enemy");
|
c.beRepaired(10);
|
||||||
|
|
||||||
|
c.highFivesGuys();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user