diff --git a/common.mk b/common.mk index 4bfab0b..bd24137 100644 --- a/common.mk +++ b/common.mk @@ -6,14 +6,14 @@ # By: whaffman +#+ # # +#+ # # Created: 2025/03/21 15:00:16 by whaffman #+# #+# # -# Updated: 2025/03/21 15:04:44 by whaffman ######## odam.nl # +# Updated: 2025/04/07 22:48:32 by whaffman ######## odam.nl # # # # **************************************************************************** # INC = -I./inc VPATH = src OBJ = $(SRC:.cpp=.o) -CC = c++ +CC = clang++ CFLAGS = -Wall -Wextra -Werror all: $(NAME) diff --git a/ex00/src/main.cpp b/ex00/src/main.cpp index 0e27f90..94685ef 100644 --- a/ex00/src/main.cpp +++ b/ex00/src/main.cpp @@ -6,55 +6,53 @@ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2025/03/27 16:56:23 by whaffman #+# #+# */ -/* Updated: 2025/04/07 15:45:50 by whaffman ######## odam.nl */ +/* Updated: 2025/04/07 22:38:04 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ #include "ClapTrap.hpp" #include +void claptrap_test() +{ + std::cout << COLOR9 << "ClapTrap tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "Constructor & assignment tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "ClapTrap Alice with parameter constructor" << COLOR_RESET << std::endl; + ClapTrap alice("Alice"); + std::cout << COLOR10 << "Claptrap alice_copy with copy constructor of Alice" << COLOR_RESET << std::endl; + ClapTrap alice_copy(alice); + std::cout << COLOR10 << "default_claptrap with default constructor" << COLOR_RESET << std::endl; + ClapTrap default_claptrap; + std::cout << COLOR10 << "default_claptrap = alice" << COLOR_RESET << std::endl; + default_claptrap = alice; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: alice" << COLOR_RESET << std::endl; + alice.attack("enemy"); + alice.takeDamage(5); + alice.beRepaired(3); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: alice_copy" << COLOR_RESET << std::endl; + alice_copy.attack("enemy"); + alice_copy.takeDamage(15); + alice_copy.attack("the sun"); + for(int i = 0; i < 10; i++) + alice_copy.beRepaired(1); + alice_copy.attack("the moon"); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: default_claptrap" << COLOR_RESET << std::endl; + default_claptrap.attack("enemy"); + default_claptrap.takeDamage(5); + std::cout << std::endl; + + std::cout << COLOR10 << "Destructor tests" << COLOR_RESET << std::endl; +} + int main() { - std::cout << COLOR10 << "Constructor & assignment tests" << COLOR_RESET << std::endl; - std::cout << COLOR10 << "claptrap with parameter constructor" << COLOR_RESET << std::endl; - ClapTrap claptrap("Rudolph"); - std::cout << COLOR10 << "claptrap2 with copy constructor" << COLOR_RESET << std::endl; - ClapTrap claptrap2(claptrap); - std::cout << COLOR10 << "Claptrap3 with default constructor" << COLOR_RESET << std::endl; - ClapTrap claptrap3; - std::cout << COLOR10 << "claptrap3 = claptrap" << COLOR_RESET << std::endl; - claptrap3 = claptrap; - std::cout << COLOR10 << "claptrap4 with parameter constructor" << COLOR_RESET << std::endl; - ClapTrap claptrap4("Eduard"); - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap" << COLOR_RESET << std::endl; - claptrap.attack("enemy"); - claptrap.takeDamage(5); - claptrap.beRepaired(3); - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap2" << COLOR_RESET << std::endl; - claptrap2.attack("enemy"); - claptrap2.takeDamage(15); - claptrap2.attack("the sun"); - for(int i = 0; i < 10; i++) - claptrap2.beRepaired(1); - claptrap2.attack("the moon"); - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap3" << COLOR_RESET << std::endl; - claptrap3.attack("enemy"); - claptrap3.takeDamage(5); - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap4" << COLOR_RESET << std::endl; - claptrap4.attack("itself"); - claptrap4.takeDamage(5); - claptrap4.beRepaired(4); - - std::cout << std::endl; - std::cout << COLOR10 << "Destructor tests" << COLOR_RESET << std::endl; - + std::cout << "Starting tests..." << std::endl; + claptrap_test(); + return 0; } \ No newline at end of file diff --git a/ex01/src/main.cpp b/ex01/src/main.cpp index bf15627..b7bd984 100644 --- a/ex01/src/main.cpp +++ b/ex01/src/main.cpp @@ -6,7 +6,7 @@ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2025/03/28 11:35:59 by whaffman #+# #+# */ -/* Updated: 2025/04/07 16:22:19 by whaffman ######## odam.nl */ +/* Updated: 2025/04/07 22:39:55 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -14,61 +14,86 @@ #include "ClapTrap.hpp" #include "ScavTrap.hpp" +void claptrap_test() +{ + std::cout << COLOR9 << "ClapTrap tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "Constructor & assignment tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "ClapTrap Alice with parameter constructor" << COLOR_RESET << std::endl; + ClapTrap alice("Alice"); + std::cout << COLOR10 << "Claptrap alice_copy with copy constructor of Alice" << COLOR_RESET << std::endl; + ClapTrap alice_copy(alice); + std::cout << COLOR10 << "default_claptrap with default constructor" << COLOR_RESET << std::endl; + ClapTrap default_claptrap; + std::cout << COLOR10 << "default_claptrap = alice" << COLOR_RESET << std::endl; + default_claptrap = alice; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: alice" << COLOR_RESET << std::endl; + alice.attack("enemy"); + alice.takeDamage(5); + alice.beRepaired(3); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: alice_copy" << COLOR_RESET << std::endl; + alice_copy.attack("enemy"); + alice_copy.takeDamage(15); + alice_copy.attack("the sun"); + for(int i = 0; i < 10; i++) + alice_copy.beRepaired(1); + alice_copy.attack("the moon"); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: default_claptrap" << COLOR_RESET << std::endl; + default_claptrap.attack("enemy"); + default_claptrap.takeDamage(5); + std::cout << std::endl; + + std::cout << COLOR10 << "Destructor tests" << COLOR_RESET << std::endl; +} + +void scavtrap_test() +{ + std::cout << COLOR9 << "ScavTrap tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "Constructor & assignment tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "ScavTrap Bob with parameter constructor" << COLOR_RESET << std::endl; + ScavTrap bob("Bob"); + std::cout << COLOR10 << "Scavtrap bob_copy with copy constructor of Bob" << COLOR_RESET << std::endl; + ScavTrap bob_copy(bob); + std::cout << COLOR10 << "default_scavtrap with default constructor" << COLOR_RESET << std::endl; + ScavTrap default_scavtrap; + std::cout << COLOR10 << "default_scavtrap = bob" << COLOR_RESET << std::endl; + default_scavtrap = bob; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: bob" << COLOR_RESET << std::endl; + bob.attack("enemy"); + bob.takeDamage(5); + bob.beRepaired(3); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: bob_copy" << COLOR_RESET << std::endl; + bob_copy.attack("enemy"); + bob_copy.takeDamage(15); + bob_copy.attack("the sun"); + for(int i = 0; i < 10; i++) + bob_copy.beRepaired(1); + bob_copy.attack("the moon"); + bob_copy.guardGate(); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: default_scavtrap" << COLOR_RESET << std::endl; + default_scavtrap.attack("enemy"); + default_scavtrap.takeDamage(5); + default_scavtrap.guardGate(); + std::cout << std::endl; + + std::cout << COLOR10 << "Destructor tests" << COLOR_RESET << std::endl; +} + int main() { - std::cout << COLOR10 << "Constructor & assignment tests" << COLOR_RESET << std::endl; - std::cout << COLOR10 << "claptrap with parameter constructor" << COLOR_RESET << std::endl; - ScavTrap claptrap("Rudolph"); - std::cout << std::endl; - - std::cout << COLOR10 << "claptrap2 with copy constructor" << COLOR_RESET << std::endl; - ScavTrap claptrap2(claptrap); - std::cout << std::endl; - - std::cout << COLOR10 << "Claptrap3 with default constructor" << COLOR_RESET << std::endl; - ScavTrap claptrap3; - std::cout << std::endl; - - std::cout << COLOR10 << "claptrap3 = claptrap" << COLOR_RESET << std::endl; - claptrap3 = claptrap; - std::cout << std::endl; - - std::cout << COLOR10 << "claptrap4 with parameter constructor" << COLOR_RESET << std::endl; - ScavTrap claptrap4("Eduard"); - - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap" << COLOR_RESET << std::endl; - claptrap.attack("enemy"); - claptrap.takeDamage(5); - claptrap.beRepaired(3); - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap2" << COLOR_RESET << std::endl; - claptrap2.attack("enemy"); - claptrap2.takeDamage(15); - claptrap2.attack("the sun"); - for(int i = 0; i < 10; i++) - claptrap2.beRepaired(1); - claptrap2.attack("the moon"); - claptrap2.guardGate(); - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap3" << COLOR_RESET << std::endl; - claptrap3.attack("enemy"); - claptrap3.takeDamage(5); - claptrap3.guardGate(); - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap4" << COLOR_RESET << std::endl; - claptrap4.attack("itself"); - claptrap4.takeDamage(5); - claptrap4.beRepaired(4); - claptrap4.guardGate(); - claptrap4.attack("enemy"); - - std::cout << std::endl; - std::cout << COLOR10 << "Destructor tests" << COLOR_RESET << std::endl; - + std::cout << "Starting tests..." << std::endl; + claptrap_test(); + scavtrap_test(); + std::cout << COLOR9 << "All tests completed" << COLOR_RESET << std::endl; + return (0); } \ No newline at end of file diff --git a/ex02/src/main.cpp b/ex02/src/main.cpp index 55951a8..1af4773 100644 --- a/ex02/src/main.cpp +++ b/ex02/src/main.cpp @@ -6,7 +6,7 @@ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2025/03/28 11:35:59 by whaffman #+# #+# */ -/* Updated: 2025/04/07 16:32:00 by whaffman ######## odam.nl */ +/* Updated: 2025/04/07 22:41:10 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -15,61 +15,125 @@ #include "ScavTrap.hpp" #include "FragTrap.hpp" +void claptrap_test() +{ + std::cout << COLOR9 << "ClapTrap tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "Constructor & assignment tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "ClapTrap Alice with parameter constructor" << COLOR_RESET << std::endl; + ClapTrap alice("Alice"); + std::cout << COLOR10 << "Claptrap alice_copy with copy constructor of Alice" << COLOR_RESET << std::endl; + ClapTrap alice_copy(alice); + std::cout << COLOR10 << "default_claptrap with default constructor" << COLOR_RESET << std::endl; + ClapTrap default_claptrap; + std::cout << COLOR10 << "default_claptrap = alice" << COLOR_RESET << std::endl; + default_claptrap = alice; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: alice" << COLOR_RESET << std::endl; + alice.attack("enemy"); + alice.takeDamage(5); + alice.beRepaired(3); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: alice_copy" << COLOR_RESET << std::endl; + alice_copy.attack("enemy"); + alice_copy.takeDamage(15); + alice_copy.attack("the sun"); + for(int i = 0; i < 10; i++) + alice_copy.beRepaired(1); + alice_copy.attack("the moon"); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: default_claptrap" << COLOR_RESET << std::endl; + default_claptrap.attack("enemy"); + default_claptrap.takeDamage(5); + std::cout << std::endl; + + std::cout << COLOR10 << "Destructor tests" << COLOR_RESET << std::endl; +} + +void scavtrap_test() +{ + std::cout << COLOR9 << "ScavTrap tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "Constructor & assignment tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "ScavTrap Bob with parameter constructor" << COLOR_RESET << std::endl; + ScavTrap bob("Bob"); + std::cout << COLOR10 << "Scavtrap bob_copy with copy constructor of Bob" << COLOR_RESET << std::endl; + ScavTrap bob_copy(bob); + std::cout << COLOR10 << "default_scavtrap with default constructor" << COLOR_RESET << std::endl; + ScavTrap default_scavtrap; + std::cout << COLOR10 << "default_scavtrap = bob" << COLOR_RESET << std::endl; + default_scavtrap = bob; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: bob" << COLOR_RESET << std::endl; + bob.attack("enemy"); + bob.takeDamage(5); + bob.beRepaired(3); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: bob_copy" << COLOR_RESET << std::endl; + bob_copy.attack("enemy"); + bob_copy.takeDamage(15); + bob_copy.attack("the sun"); + for(int i = 0; i < 10; i++) + bob_copy.beRepaired(1); + bob_copy.attack("the moon"); + bob_copy.guardGate(); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: default_scavtrap" << COLOR_RESET << std::endl; + default_scavtrap.attack("enemy"); + default_scavtrap.takeDamage(5); + default_scavtrap.guardGate(); + std::cout << std::endl; + + std::cout << COLOR10 << "Destructor tests" << COLOR_RESET << std::endl; +} + +void fragtrap_test() +{ + std::cout << COLOR9 << "FragTrap tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "Constructor & assignment tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "FragTrap Charlie with parameter constructor" << COLOR_RESET << std::endl; + FragTrap charlie("Charlie"); + std::cout << COLOR10 << "Fragtrap charlie_copy with copy constructor of Charlie" << COLOR_RESET << std::endl; + FragTrap charlie_copy(charlie); + std::cout << COLOR10 << "default_fragtrap with default constructor" << COLOR_RESET << std::endl; + FragTrap default_fragtrap; + std::cout << COLOR10 << "default_fragtrap = charlie" << COLOR_RESET << std::endl; + default_fragtrap = charlie; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: charlie" << COLOR_RESET << std::endl; + charlie.attack("enemy"); + charlie.takeDamage(5); + charlie.beRepaired(3); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: charlie_copy" << COLOR_RESET << std::endl; + charlie_copy.attack("enemy"); + charlie_copy.takeDamage(15); + charlie_copy.attack("the sun"); + for(int i = 0; i < 10; i++) + charlie_copy.beRepaired(1); + charlie_copy.attack("the moon"); + charlie_copy.highFivesGuys(); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: default_fragtrap" << COLOR_RESET << std::endl; + default_fragtrap.attack("enemy"); + default_fragtrap.takeDamage(5); + default_fragtrap.highFivesGuys(); + std::cout << std::endl; + + std::cout << COLOR10 << "Destructor tests" << COLOR_RESET << std::endl; +} + int main() { - std::cout << COLOR10 << "Constructor & assignment tests" << COLOR_RESET << std::endl; - std::cout << COLOR10 << "claptrap with parameter constructor" << COLOR_RESET << std::endl; - FragTrap claptrap("Rudolph"); - std::cout << std::endl; - - std::cout << COLOR10 << "claptrap2 with copy constructor" << COLOR_RESET << std::endl; - FragTrap claptrap2(claptrap); - std::cout << std::endl; - - std::cout << COLOR10 << "Claptrap3 with default constructor" << COLOR_RESET << std::endl; - FragTrap claptrap3; - std::cout << std::endl; - - std::cout << COLOR10 << "claptrap3 = claptrap" << COLOR_RESET << std::endl; - claptrap3 = claptrap; - std::cout << std::endl; - - std::cout << COLOR10 << "claptrap4 with parameter constructor" << COLOR_RESET << std::endl; - FragTrap claptrap4("Eduard"); - - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap" << COLOR_RESET << std::endl; - claptrap.attack("enemy"); - claptrap.takeDamage(5); - claptrap.beRepaired(3); - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap2" << COLOR_RESET << std::endl; - claptrap2.attack("enemy"); - claptrap2.takeDamage(15); - claptrap2.attack("the sun"); - for(int i = 0; i < 10; i++) - claptrap2.takeDamage(15); - claptrap2.attack("the moon"); - claptrap2.highFivesGuys(); - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap3" << COLOR_RESET << std::endl; - claptrap3.attack("enemy"); - claptrap3.takeDamage(5); - claptrap3.highFivesGuys(); - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap4" << COLOR_RESET << std::endl; - claptrap4.attack("itself"); - claptrap4.takeDamage(5); - claptrap4.beRepaired(4); - claptrap4.highFivesGuys(); - claptrap4.attack("enemy"); - - std::cout << std::endl; - std::cout << COLOR10 << "Destructor tests" << COLOR_RESET << std::endl; - + std::cout << "Starting tests..." << std::endl; + claptrap_test(); + scavtrap_test(); + fragtrap_test(); + std::cout << COLOR9 << "All tests completed!" << COLOR_RESET << std::endl; + return (0); } \ No newline at end of file diff --git a/ex03/src/ClapTrap.cpp b/ex03/src/ClapTrap.cpp index 2386448..3eb4c2e 100644 --- a/ex03/src/ClapTrap.cpp +++ b/ex03/src/ClapTrap.cpp @@ -16,8 +16,13 @@ ClapTrap::ClapTrap(std::string name) : _name(name), _hitpoints(10), _energy_poin ClapTrap::ClapTrap(ClapTrap const &src) { + _name = src._name; + _hitpoints = src._hitpoints; + _energy_points = src._energy_points; + _attack_damage = src._attack_damage; + std::cout << COLOR12 << "Claptrap " << COLOR_RESET << _name << " is copied!" << std::endl; - *this = src; + status(); } diff --git a/ex03/src/DiamondTrap.cpp b/ex03/src/DiamondTrap.cpp index e24e160..76b4f2b 100644 --- a/ex03/src/DiamondTrap.cpp +++ b/ex03/src/DiamondTrap.cpp @@ -25,13 +25,15 @@ DiamondTrap::DiamondTrap(std::string name) : ClapTrap(name + "_clap_name"), _nam status(); } -DiamondTrap::DiamondTrap(DiamondTrap const &src) +DiamondTrap::DiamondTrap(DiamondTrap const &src) : ClapTrap(src), FragTrap(src), ScavTrap(src) { - *this = src; + _name = src._name; + std::cout << COLOR11 << "Diamondtrap " << COLOR_RESET << _name << " has been created by copy constructor" << std::endl; status(); } + DiamondTrap::~DiamondTrap() { std::cout << COLOR11 << "Diamondtrap " << COLOR_RESET << _name << " has been destroyed" << std::endl; diff --git a/ex03/src/FragTrap.cpp b/ex03/src/FragTrap.cpp index 423893d..004bf81 100644 --- a/ex03/src/FragTrap.cpp +++ b/ex03/src/FragTrap.cpp @@ -17,10 +17,9 @@ FragTrap::FragTrap(std::string name) : ClapTrap(name) std::cout << COLOR14 << "FragTrap " << COLOR_RESET << _name << " has been created" << std::endl; status(); } -FragTrap::FragTrap(FragTrap const &src) +FragTrap::FragTrap(FragTrap const &src) : ClapTrap(src) { std::cout << COLOR14 << "FragTrap " << COLOR_RESET << _name << " has been created by copy constructor" << std::endl; - *this = src; status(); } diff --git a/ex03/src/ScavTrap.cpp b/ex03/src/ScavTrap.cpp index 5e39173..c5b863b 100644 --- a/ex03/src/ScavTrap.cpp +++ b/ex03/src/ScavTrap.cpp @@ -6,7 +6,7 @@ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2025/03/28 11:32:48 by whaffman #+# #+# */ -/* Updated: 2025/04/07 17:34:50 by whaffman ######## odam.nl */ +/* Updated: 2025/04/07 23:01:15 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -30,11 +30,9 @@ ScavTrap::ScavTrap(std::string name) : ClapTrap(name), _guard_mode(false) status(); } -ScavTrap::ScavTrap(ScavTrap const &src) : ClapTrap(src) +ScavTrap::ScavTrap(ScavTrap const &src) : ClapTrap(src), _guard_mode(src._guard_mode) { - *this = src; - - std::cout << COLOR13 << "Scavtrap " << COLOR_RESET << _name << " has been created by copy constructor" << std::endl; + _name = src._name; std::cout << COLOR13 << "Scavtrap " << COLOR_RESET << _name << " has been created by copy constructor" << std::endl; status(); } diff --git a/ex03/src/main.cpp b/ex03/src/main.cpp index caf83b2..976e9fe 100644 --- a/ex03/src/main.cpp +++ b/ex03/src/main.cpp @@ -6,7 +6,7 @@ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2025/03/28 11:35:59 by whaffman #+# #+# */ -/* Updated: 2025/04/07 17:25:03 by whaffman ######## odam.nl */ +/* Updated: 2025/04/07 22:42:18 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -16,63 +16,168 @@ #include "FragTrap.hpp" #include "DiamondTrap.hpp" +void claptrap_test() +{ + std::cout << COLOR9 << "ClapTrap tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "Constructor & assignment tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "ClapTrap Alice with parameter constructor" << COLOR_RESET << std::endl; + ClapTrap alice("Alice"); + std::cout << COLOR10 << "Claptrap alice_copy with copy constructor of Alice" << COLOR_RESET << std::endl; + ClapTrap alice_copy(alice); + std::cout << COLOR10 << "default_claptrap with default constructor" << COLOR_RESET << std::endl; + ClapTrap default_claptrap; + std::cout << COLOR10 << "default_claptrap = alice" << COLOR_RESET << std::endl; + default_claptrap = alice; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: alice" << COLOR_RESET << std::endl; + alice.attack("enemy"); + alice.takeDamage(5); + alice.beRepaired(3); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: alice_copy" << COLOR_RESET << std::endl; + alice_copy.attack("enemy"); + alice_copy.takeDamage(15); + alice_copy.attack("the sun"); + for(int i = 0; i < 10; i++) + alice_copy.beRepaired(1); + alice_copy.attack("the moon"); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: default_claptrap" << COLOR_RESET << std::endl; + default_claptrap.attack("enemy"); + default_claptrap.takeDamage(5); + std::cout << std::endl; + + std::cout << COLOR10 << "Destructor tests" << COLOR_RESET << std::endl; +} + +void scavtrap_test() +{ + std::cout << COLOR9 << "ScavTrap tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "Constructor & assignment tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "ScavTrap Bob with parameter constructor" << COLOR_RESET << std::endl; + ScavTrap bob("Bob"); + std::cout << COLOR10 << "Scavtrap bob_copy with copy constructor of Bob" << COLOR_RESET << std::endl; + ScavTrap bob_copy(bob); + std::cout << COLOR10 << "default_scavtrap with default constructor" << COLOR_RESET << std::endl; + ScavTrap default_scavtrap; + std::cout << COLOR10 << "default_scavtrap = bob" << COLOR_RESET << std::endl; + default_scavtrap = bob; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: bob" << COLOR_RESET << std::endl; + bob.attack("enemy"); + bob.takeDamage(5); + bob.beRepaired(3); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: bob_copy" << COLOR_RESET << std::endl; + bob_copy.attack("enemy"); + bob_copy.takeDamage(15); + bob_copy.attack("the sun"); + for(int i = 0; i < 10; i++) + bob_copy.beRepaired(1); + bob_copy.attack("the moon"); + bob_copy.guardGate(); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: default_scavtrap" << COLOR_RESET << std::endl; + default_scavtrap.attack("enemy"); + default_scavtrap.takeDamage(5); + default_scavtrap.guardGate(); + std::cout << std::endl; + + std::cout << COLOR10 << "Destructor tests" << COLOR_RESET << std::endl; +} + +void fragtrap_test() +{ + std::cout << COLOR9 << "FragTrap tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "Constructor & assignment tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "FragTrap Charlie with parameter constructor" << COLOR_RESET << std::endl; + FragTrap charlie("Charlie"); + std::cout << COLOR10 << "Fragtrap charlie_copy with copy constructor of Charlie" << COLOR_RESET << std::endl; + FragTrap charlie_copy(charlie); + std::cout << COLOR10 << "default_fragtrap with default constructor" << COLOR_RESET << std::endl; + FragTrap default_fragtrap; + std::cout << COLOR10 << "default_fragtrap = charlie" << COLOR_RESET << std::endl; + default_fragtrap = charlie; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: charlie" << COLOR_RESET << std::endl; + charlie.attack("enemy"); + charlie.takeDamage(5); + charlie.beRepaired(3); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: charlie_copy" << COLOR_RESET << std::endl; + charlie_copy.attack("enemy"); + charlie_copy.takeDamage(15); + charlie_copy.attack("the sun"); + for(int i = 0; i < 10; i++) + charlie_copy.beRepaired(1); + charlie_copy.attack("the moon"); + charlie_copy.highFivesGuys(); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: default_fragtrap" << COLOR_RESET << std::endl; + default_fragtrap.attack("enemy"); + default_fragtrap.takeDamage(5); + default_fragtrap.highFivesGuys(); + std::cout << std::endl; + + std::cout << COLOR10 << "Destructor tests" << COLOR_RESET << std::endl; +} + +void diamondtrap_test() +{ + std::cout << COLOR9 << "DiamondTrap tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "Constructor & assignment tests" << COLOR_RESET << std::endl; + std::cout << COLOR10 << "DiamondTrap Diamond with parameter constructor" << COLOR_RESET << std::endl; + DiamondTrap diamond("Diamond"); + std::cout << COLOR10 << "Diamondtrap diamond_copy with copy constructor of Diamond" << COLOR_RESET << std::endl; + DiamondTrap diamond_copy(diamond); + std::cout << COLOR10 << "default_diamondtrap with default constructor" << COLOR_RESET << std::endl; + DiamondTrap default_diamondtrap; + std::cout << COLOR10 << "default_diamondtrap = diamond" << COLOR_RESET << std::endl; + default_diamondtrap = diamond; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: diamond" << COLOR_RESET << std::endl; + diamond.attack("enemy"); + diamond.takeDamage(5); + diamond.beRepaired(3); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: diamond_copy" << COLOR_RESET << std::endl; + diamond_copy.attack("enemy"); + diamond_copy.takeDamage(15); + diamond_copy.attack("the sun"); + for(int i = 0; i < 10; i++) + diamond_copy.beRepaired(1); + diamond_copy.attack("the moon"); + diamond_copy.highFivesGuys(); + diamond_copy.guardGate(); + diamond_copy.whoAmI(); + std::cout << std::endl; + + std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: default_diamondtrap" << COLOR_RESET << std::endl; + default_diamondtrap.attack("enemy"); + default_diamondtrap.takeDamage(5); + default_diamondtrap.highFivesGuys(); + default_diamondtrap.guardGate(); + default_diamondtrap.whoAmI(); + std::cout << std::endl; + + std::cout << COLOR10 << "Destructor tests" << COLOR_RESET << std::endl; +} + int main() { - std::cout << COLOR10 << "Constructor & assignment tests" << COLOR_RESET << std::endl; - std::cout << COLOR10 << "claptrap with parameter constructor" << COLOR_RESET << std::endl; - DiamondTrap claptrap("Rudolph"); - std::cout << std::endl; + std::cout << "Starting tests..." << std::endl; + claptrap_test(); + scavtrap_test(); + fragtrap_test(); + diamondtrap_test(); - std::cout << COLOR10 << "claptrap2 with copy constructor" << COLOR_RESET << std::endl; - DiamondTrap claptrap2(claptrap); - std::cout << std::endl; - - std::cout << COLOR10 << "Claptrap3 with default constructor" << COLOR_RESET << std::endl; - DiamondTrap claptrap3; - std::cout << std::endl; - - std::cout << COLOR10 << "claptrap3 = claptrap" << COLOR_RESET << std::endl; - claptrap3 = claptrap; - std::cout << std::endl; - - std::cout << COLOR10 << "claptrap4 with parameter constructor" << COLOR_RESET << std::endl; - DiamondTrap claptrap4("Eduard"); - - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap" << COLOR_RESET << std::endl; - claptrap.attack("enemy"); - claptrap.takeDamage(5); - claptrap.beRepaired(3); - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap2" << COLOR_RESET << std::endl; - claptrap2.attack("enemy"); - claptrap2.takeDamage(15); - claptrap2.attack("the sun"); - for(int i = 0; i < 10; i++) - claptrap2.takeDamage(15); - claptrap2.attack("the moon"); - claptrap2.highFivesGuys(); - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap3" << COLOR_RESET << std::endl; - claptrap3.attack("enemy"); - claptrap3.takeDamage(5); - claptrap3.highFivesGuys(); - claptrap3.guardGate(); - claptrap3.whoAmI(); - std::cout << std::endl; - - std::cout << COLOR10 << "Attack, takeDamage and beRepaired tests: claptrap4" << COLOR_RESET << std::endl; - claptrap4.attack("itself"); - claptrap4.takeDamage(5); - claptrap4.beRepaired(4); - claptrap4.highFivesGuys(); - claptrap4.attack("enemy"); - - std::cout << std::endl; - std::cout << COLOR10 << "Destructor tests" << COLOR_RESET << std::endl; - - return (0); + std::cout << COLOR9 << "All tests completed successfully!" << COLOR_RESET << std::endl; + return 0; } \ No newline at end of file