From 8fc4395b9a61416e9bfee500e064dce7be9c8d7c Mon Sep 17 00:00:00 2001 From: Charles Date: Sat, 22 Feb 2020 05:43:57 +0100 Subject: cpp03 boilerplate --- cpp03/ex00/FragTrap.cpp | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ cpp03/ex00/FragTrap.hpp | 43 +++++++++++++++++++++++++ cpp03/ex00/main.cpp | 18 +++++++++++ 3 files changed, 146 insertions(+) create mode 100644 cpp03/ex00/FragTrap.cpp create mode 100644 cpp03/ex00/FragTrap.hpp create mode 100644 cpp03/ex00/main.cpp (limited to 'cpp03/ex00') diff --git a/cpp03/ex00/FragTrap.cpp b/cpp03/ex00/FragTrap.cpp new file mode 100644 index 0000000..9a68150 --- /dev/null +++ b/cpp03/ex00/FragTrap.cpp @@ -0,0 +1,85 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* FragTrap.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/22 05:20:45 by cacharle #+# #+# */ +/* Updated: 2020/02/22 05:41:11 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "FragTrap.hpp" + +FragTrap::FragTrap() : (std::string name) +{ + hitPoints = 100 + maxHitPoints = 100 + energyPoints = 100 + maxEnergyPoints = 100 + level = 1 + meleeAttackDamage = 30 + rangedAttackDamage = 20 + armorDamageReduction = 5 + std::cout << "New " << name << ": your gamer references sucks"; +} + +FragTrap::FragTrap(FragTrap const & other) +{ + name = other.name + hitPoints = other.hitPoints; + maxHitPoints = other.maxHitPoints; + energyPoints = other.energyPoints; + maxEnergyPoints = other.maxEnergyPoints; + level = other.level; + meleeAttackDamage = other.meleeAttackDamage; + rangedAttackDamage = other.rangedAttackDamage; + armorDamageReduction = other.armorDamageReduction; +} + +FragTrap FragTrap::operator=(FragTrap const & other) +{ + return FragTrap(other); +} + +FragTrap::~FragTrap() +{ + std::cout << "Delete " << name << ": your gamer references still sucks"; +} + +void FragTrap::rangedAttack(std::string const & target) +{ + std::cout << "FR4G-TP " << name << " attacks " << target + << "at range, causing " << rangedAttackDamage << " points of damage!"; +} + +void FragTrap::meleeAttack(std::string const & target) +{ + std::cout << "FR4G-TP " << name << " attacks " << target + << " causing " << meleeAttackDamage << " points of damage!"; + +} + +void FragTrap::takeDamage(unsigned int amount) +{ + if (amount > maxHitPoints) + amount = maxHitPoints + if (amount > hitPoints) + { + hitPoints = 0; + return ; + } + hitPoints -= amount; +} + +void FragTrap::beRepaired(unsigned int amount) +{ + if (amound + hitPoints > max + +} + +void FragTrap::vaulthunter_dot_exe(std::string const & target) +{ + +} diff --git a/cpp03/ex00/FragTrap.hpp b/cpp03/ex00/FragTrap.hpp new file mode 100644 index 0000000..200b412 --- /dev/null +++ b/cpp03/ex00/FragTrap.hpp @@ -0,0 +1,43 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* FragTrap.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/22 05:17:16 by cacharle #+# #+# */ +/* Updated: 2020/02/22 05:40:56 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FRAGTRAP_CPP +# define FRAGTRAP_CPP + +# include + +class FragTrap +{ + FragTrap(); + FragTrap(FragTrap const & other); + FragTrap operator=(FragTrap const & other); + ~FragTrap(); + + rangedAttack(std::string const & target); + meleeAttack(std::string const & target); + takeDamage(unsigned int amount); + beRepaired(unsigned int amount); + vaulthunter_dot_exe(std::string const & target); + + protected: + std::string name; + int hitPoints; + int maxHitPoints; + int energyPoints; + int maxEnergyPoints; + int level; + int meleeAttackDamage; + int rangedAttackDamage; + int armorDamageReduction; +}; + +#endif diff --git a/cpp03/ex00/main.cpp b/cpp03/ex00/main.cpp new file mode 100644 index 0000000..c1059f5 --- /dev/null +++ b/cpp03/ex00/main.cpp @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/22 05:41:27 by cacharle #+# #+# */ +/* Updated: 2020/02/22 05:41:48 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "FragTrap.hpp" + +int main(void) +{ + return 0; +} -- cgit