d03 code refonte ex00 01 et 02

This commit is contained in:
Hugo LAMY
2022-02-22 19:05:24 +01:00
parent 088a54d036
commit 8c9d50dd68
12 changed files with 349 additions and 330 deletions

View File

@@ -1,96 +1,109 @@
#include "ClapTrap.hpp"
/*
* default/parametric constructor
*/
# define B_GRAY "\e[1;30m"
# define B_RED "\e[1;31m"
# define B_GREEN "\e[1;32m"
# define B_YELLOW "\e[1;33m"
# define B_BLUE "\e[1;34m"
# define B_PURPLE "\e[1;35m"
# define B_CYAN "\e[1;36m"
# define B_WHITE "\e[1;37m"
ClapTrap::ClapTrap( void ) {
std::cout << "claptrap created without name\n";
# define RESET "\e[0m"
/*********************************************
* CONSTRUCTORS
*********************************************/
ClapTrap::ClapTrap( std::string name ) {
ClapTrap::_increaseNumber();
_class = _dClass;
_name = name;
_hit = _dHit;
_energy = _dEnergy;
_attack = _dAttack;
_number = getTotalNumber();
std::cout << _class << " " << _name << "-" << _number << " created\n";
return;
}
/*
* destructor
*/
ClapTrap::~ClapTrap( void ) {
std::cout << "claptrap " << _name << " destructed\n";
return;
}
/*
* copy constructor
*/
ClapTrap::ClapTrap( ClapTrap const & src ) {
std::cout << "claptrap " << _name << " copied\n";
ClapTrap::_increaseNumber();
_class = _dClass;
*this = src;
_number = getTotalNumber();
std::cout << _class << " " << _name << "-" << _number << " copied from " << src._class << " " << src._name << "-" << src._number << "\n";
return;
}
/*
* assignement operator
*/
/*********************************************
* DESTRUCTORS
*********************************************/
ClapTrap::~ClapTrap( void ) {
std::cout << _class << " " << _name << "-" << _number << " destructed\n";
return;
}
/*********************************************
* OPERATORS
*********************************************/
ClapTrap & ClapTrap::operator=( ClapTrap const & rhs ) {
std::cout << "claptrap " << _name << " assigned\n";
if ( this != &rhs )
{
this->_hit = rhs.getHit();
this->_energy = rhs.getEnergy();
this->_attack = rhs.getAttack();
_name = rhs.getName();
_hit = rhs.getHit();
_energy = rhs.getEnergy();
_attack = rhs.getAttack();
_number = rhs.getNumber();
}
std::cout << _class << " " << _name << "-" << _number << " assigned\n";
return *this;
}
/*
* constructor
*/
ClapTrap::ClapTrap( std::string name ) : _name(name) {
std::cout << "claptrap " << _name << " created\n";
_hit = 10;
_energy = 10;
_attack = 1;
return;
}
/*
* getters
*/
/*********************************************
* ACCESSORS
*********************************************/
std::string ClapTrap::getName() const {return _name;}
std::string ClapTrap::getClass() const {return _class;}
int ClapTrap::getHit() const {return _hit;}
int ClapTrap::getEnergy() const {return _energy;}
int ClapTrap::getAttack() const {return _attack;}
int ClapTrap::getNumber() const {return _number;}
int ClapTrap::getTotalNumber() const {return _totalNumber;}
void ClapTrap::_increaseNumber() {ClapTrap::_totalNumber++;}
/*
* robots
*/
/*********************************************
* PUBLIC MEMBER FUNCTIONS
*********************************************/
void ClapTrap::attack(const std::string & target) {
std::ostringstream action;
std::ostringstream state;
state << B_CYAN "[" B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->";
action << " ClapTrap " << _name;
state << B_CYAN "[" B_GREEN << _class[0] << _number << B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->";
action << _class << " " << _name << "-" << _number;
if (_energy && _hit)
if (_energy > 0 && _hit > 0)
{
_energy--;
action << " attacked " << target << ", causing " B_YELLOW << _attack << RESET << " points of damage!" << '\n';
if (_energy < 0)
_energy = 0;
action << " attacked " << target << ", causing " B_YELLOW << _attack << RESET << " points of damage" << '\n';
}
else
{
_attack = 0;
if (!_energy)
action << "cannot attack because " B_RED " is out of energy\n" RESET;
else if (!_hit)
action << "cannot attack because " B_RED " is out of hit\n" RESET;
if (_energy <= 0)
action << " cannot attack because " B_RED " is out of energy" RESET"\n";
else if (_hit <= 0)
action << " cannot attack because " B_RED " is out of hit" RESET "\n";
}
state << B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "]" RESET;
@@ -102,21 +115,18 @@ void ClapTrap::takeDamage(unsigned int amount) {
std::ostringstream action;
std::ostringstream state;
state << B_CYAN "[" B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->";
action << " ClapTrap " << _name;
state << B_CYAN "[" B_GREEN << _class[0] << _number << B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->";
action << _class << " " << _name << "-" << _number;
if (_energy && _hit)
if (_hit > 0)
{
_hit -= amount;
action << " looses " B_YELLOW << amount << RESET << " points of damage :/" << '\n';
}
else
{
if (!_energy)
action << "cannot take damage because " B_RED " is out of energy\n" RESET;
else if (!_hit)
action << "cannot take damage because " B_RED " is out of hit\n" RESET;
if (_hit < 0)
_hit = 0;
action << " looses " B_YELLOW << amount << RESET << " hit points" << '\n';
}
else if (_hit <= 0)
action << " cannot take damage because " B_RED " is out of hit" RESET "\n";
state << B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "]" RESET;
std::cout << state.str() << action.str();
@@ -127,23 +137,38 @@ void ClapTrap::beRepaired(unsigned int amount) {
std::ostringstream action;
std::ostringstream state;
state << B_CYAN "[" B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->";
action << " ClapTrap " << _name;
state << B_CYAN "[" B_GREEN << _class[0] << _number << B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->";
action << _class << " " << _name << "-" << _number;
if (_energy && _hit)
if (_energy > 0 && _hit > 0)
{
_energy--;
if (_energy < 0)
_energy = 0;
_hit += amount;
action << " repaired itself and gained " B_YELLOW << amount << RESET << " points of life :)" << '\n';
action << " repaired itself and gained " B_YELLOW << amount << RESET << " points of life" << '\n';
}
else
{
if (!_energy)
action << "cannot repair itself because " B_RED " is out of energy\n" RESET;
else if (!_hit)
action << "cannot repair itself because " B_RED " is out of hit\n" RESET;
if (_energy <= 0)
action << " cannot repair itself because " B_RED " is out of energy" RESET "\n";
else if (_hit <= 0)
action << " cannot repair itself because " B_RED " is out of hit" RESET "\n";
}
state << B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "]" RESET;
std::cout << state.str() << action.str();
}
/*********************************************
* STATICS
*********************************************/
int ClapTrap::_totalNumber = 0;
std::string const ClapTrap::_dName = "robot";
std::string const ClapTrap::_dClass = "ClapTrap";
int const ClapTrap::_dHit = 10;
int const ClapTrap::_dEnergy = 10;
int const ClapTrap::_dAttack = 0;

View File

@@ -4,14 +4,13 @@
#include <iostream>
#include <sstream>
#include <string>
#include <color.h>
class ClapTrap {
public:
ClapTrap( std::string name ); // default/parametric constructor
ClapTrap( ClapTrap const & src ); // copy constructor
ClapTrap( std::string name = ClapTrap::_dName );
ClapTrap( ClapTrap const & src ); // copy constructor
~ClapTrap( void ); // destructor
ClapTrap & operator=( ClapTrap const & rhs ); // assignement operator
@@ -21,18 +20,36 @@ public:
void beRepaired(unsigned int amount);
std::string getName() const;
std::string getClass() const;
int getHit() const;
int getEnergy() const;
int getAttack() const;
int getNumber() const;
protected:
int getTotalNumber() const;
std::string _name;
std::string _class;
int _hit;
int _energy;
int _attack;
int _number;
void _increaseNumber();
private:
ClapTrap( void ); // default/parametric constructor
void assignValues(ClapTrap & src);
static int _totalNumber;
std::string const _name;
int _hit;
int _energy;
int _attack;
static const std::string _dName;
static const std::string _dClass;
static const int _dHit;
static const int _dEnergy;
static const int _dAttack;
static const int _dNumber;
};

View File

@@ -1,24 +0,0 @@
#ifndef COLOR_H
# define COLOR_H
# define GRAY "\e[0;30m"
# define RED "\e[0;31m"
# define GREEN "\e[0;32m"
# define YELLOW "\e[0;33m"
# define BLUE "\e[0;34m"
# define PURPLE "\e[0;35m"
# define CYAN "\e[0;36m"
# define WHITE "\e[0;37m"
# define B_GRAY "\e[1;30m"
# define B_RED "\e[1;31m"
# define B_GREEN "\e[1;32m"
# define B_YELLOW "\e[1;33m"
# define B_BLUE "\e[1;34m"
# define B_PURPLE "\e[1;35m"
# define B_CYAN "\e[1;36m"
# define B_WHITE "\e[1;37m"
# define RESET "\e[0m"
#endif

View File

@@ -1,90 +1,86 @@
#include "ClapTrap.hpp"
/*
* statics
*/
# define B_GRAY "\e[1;30m"
# define B_RED "\e[1;31m"
# define B_GREEN "\e[1;32m"
# define B_YELLOW "\e[1;33m"
# define B_BLUE "\e[1;34m"
# define B_PURPLE "\e[1;35m"
# define B_CYAN "\e[1;36m"
# define B_WHITE "\e[1;37m"
int ClapTrap::_totalNumber = 0;
# define RESET "\e[0m"
/*
* default/parametric constructor
*/
/*********************************************
* CONSTRUCTORS
*********************************************/
ClapTrap::ClapTrap( void ) {
std::cout << "claptrap created without name\n";
ClapTrap::ClapTrap( std::string name ) {
ClapTrap::_increaseNumber();
_class = _dClass;
_name = name;
_hit = _dHit;
_energy = _dEnergy;
_attack = _dAttack;
_number = getTotalNumber();
std::cout << _class << " " << _name << "-" << _number << " created\n";
return;
}
/*
* destructor
*/
ClapTrap::~ClapTrap( void ) {
std::cout << _class << " " << _name << " destructed\n";
return;
}
/*
* copy constructor
*/
ClapTrap::ClapTrap( ClapTrap const & src ) {
std::cout << _class << " " << _name << " copied\n";
ClapTrap::_increaseNumber();
_class = _dClass;
*this = src;
_number = getTotalNumber();
std::cout << _class << " " << _name << "-" << _number << " copied from " << src._class << " " << src._name << "-" << src._number << "\n";
return;
}
/*
* assignement operator
*/
/*********************************************
* DESTRUCTORS
*********************************************/
ClapTrap::~ClapTrap( void ) {
std::cout << _class << " " << _name << "-" << _number << " destructed\n";
return;
}
/*********************************************
* OPERATORS
*********************************************/
ClapTrap & ClapTrap::operator=( ClapTrap const & rhs ) {
if ( this != &rhs )
{
this->_hit = rhs.getHit();
this->_energy = rhs.getEnergy();
this->_attack = rhs.getAttack();
_name = rhs.getName();
_hit = rhs.getHit();
_energy = rhs.getEnergy();
_attack = rhs.getAttack();
_number = rhs.getNumber();
}
std::cout << _class << " " << _name << " assigned\n";
std::cout << _class << " " << _name << "-" << _number << " assigned\n";
return *this;
}
/*
* constructor
*/
ClapTrap::ClapTrap( std::string name ) : _name(name) {
ClapTrap::_increaseNumber();
_class = "ClapTrap";
_hit = 10;
_energy = 10;
_attack = 1;
_number = _getNumber();
std::cout << _class << " " << _name << " created with number " << _number << "\n";
return;
}
/*
* getters
*/
/*********************************************
* ACCESSORS
*********************************************/
std::string ClapTrap::getName() const {return _name;}
std::string ClapTrap::getClass() const {return _class;}
int ClapTrap::getHit() const {return _hit;}
int ClapTrap::getEnergy() const {return _energy;}
int ClapTrap::getAttack() const {return _attack;}
int ClapTrap::_getNumber() {return ClapTrap::_totalNumber;}
int ClapTrap::getNumber() const {return _number;}
int ClapTrap::getTotalNumber() const {return _totalNumber;}
void ClapTrap::_increaseNumber() {ClapTrap::_totalNumber++;}
/*
* robots
*/
/*********************************************
* PUBLIC MEMBER FUNCTIONS
*********************************************/
void ClapTrap::attack(const std::string & target) {
@@ -92,7 +88,7 @@ void ClapTrap::attack(const std::string & target) {
std::ostringstream state;
state << B_CYAN "[" B_GREEN << _class[0] << _number << B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->";
action << _class << " " << _name;
action << _class << " " << _name << "-" << _number;
if (_energy > 0 && _hit > 0)
{
@@ -120,22 +116,17 @@ void ClapTrap::takeDamage(unsigned int amount) {
std::ostringstream state;
state << B_CYAN "[" B_GREEN << _class[0] << _number << B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->";
action << _class << " " << _name;
action << _class << " " << _name << "-" << _number;
if (_energy > 0 && _hit > 0)
if (_hit > 0)
{
_hit -= amount;
if (_hit < 0)
_hit = 0;
action << " looses " B_YELLOW << amount << RESET << " hit points" << '\n';
}
else
{
if (_energy <= 0)
action << " cannot take damage because " B_RED " is out of energy" RESET "\n";
else if (_hit <= 0)
action << " cannot take damage because " B_RED " is out of hit" RESET "\n";
}
else if (_hit <= 0)
action << " cannot take damage because " B_RED " is out of hit" RESET "\n";
state << B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "]" RESET;
std::cout << state.str() << action.str();
@@ -147,7 +138,7 @@ void ClapTrap::beRepaired(unsigned int amount) {
std::ostringstream state;
state << B_CYAN "[" B_GREEN << _class[0] << _number << B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->";
action << _class << " " << _name;
action << _class << " " << _name << "-" << _number;
if (_energy > 0 && _hit > 0)
{
@@ -168,3 +159,16 @@ void ClapTrap::beRepaired(unsigned int amount) {
state << B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "]" RESET;
std::cout << state.str() << action.str();
}
/*********************************************
* STATICS
*********************************************/
int ClapTrap::_totalNumber = 0;
std::string const ClapTrap::_dName = "robot";
std::string const ClapTrap::_dClass = "ClapTrap";
int const ClapTrap::_dHit = 10;
int const ClapTrap::_dEnergy = 10;
int const ClapTrap::_dAttack = 0;

View File

@@ -4,13 +4,12 @@
#include <iostream>
#include <sstream>
#include <string>
#include <color.h>
class ClapTrap {
public:
ClapTrap( std::string name ); // default/parametric constructor
ClapTrap( std::string name = ClapTrap::_dName );
ClapTrap( ClapTrap const & src ); // copy constructor
~ClapTrap( void ); // destructor
@@ -21,28 +20,37 @@ public:
void beRepaired(unsigned int amount);
std::string getName() const;
std::string getClass() const;
int getHit() const;
int getEnergy() const;
int getAttack() const;
int getNumber() const;
protected:
std::string const _name;
std::string _class;
int _hit;
int _energy;
int _attack;
int _number;
int getTotalNumber() const;
std::string _name;
std::string _class;
int _hit;
int _energy;
int _attack;
int _number;
int _getNumber();
void _increaseNumber();
private:
ClapTrap( void ); // default/parametric constructor
void assignValues(ClapTrap & src);
static int _totalNumber;
static const std::string _dName;
static const std::string _dClass;
static const int _dHit;
static const int _dEnergy;
static const int _dAttack;
static const int _dNumber;
};
#endif

View File

@@ -1,30 +1,59 @@
#include "FragTrap.hpp"
/*********************************************
* CONSTRUCTORS
*********************************************/
FragTrap::FragTrap( std::string name ) : ClapTrap(name) {
_class = "FragTrap";
_hit = 100;
_energy = 100;
_attack = 30;
std::cout << _class << " " << FragTrap::_name << " created with number " << _number << "\n";
_class = _dClass;
_hit = _dHit;
_energy = _dEnergy;
_attack = _dAttack;
std::cout << _class << " " << _name << "-" << _number << " created\n";
return;
}
/*
* destructor
*/
FragTrap::FragTrap( FragTrap const & src ) {
_class = _dClass;
*this = src;
_number = getTotalNumber();
std::cout << _class << " " << _name << "-" << _number << " copied from " << src._class << "-" << src._name << "-" << src._number << "\n";
return;
}
/*********************************************
* DESTRUCTORS
*********************************************/
FragTrap::~FragTrap( void ) {
std::cout << _class << " " << FragTrap::_name << " destructed\n";
return;
}
/*
* special capacity
*/
/*********************************************
* OPERATORS
*********************************************/
FragTrap & FragTrap::operator=( FragTrap const & rhs ) {
ClapTrap::operator=(rhs);
return *this;
}
/*********************************************
* PUBLIC MEMBER FUNCTIONS
*********************************************/
void FragTrap::highFivesGuys() {
std::cout << _class << " " << FragTrap::_name << " wait for a high fives, common guys\n";
}
/*********************************************
* STATICS
*********************************************/
std::string const FragTrap::_dName = "robot";
std::string const FragTrap::_dClass = "FragTrap";
int const FragTrap::_dHit = 100;
int const FragTrap::_dEnergy = 100;
int const FragTrap::_dAttack = 50;

View File

@@ -8,12 +8,23 @@
class FragTrap : public ClapTrap {
public:
FragTrap( std::string name = FragTrap::_dName );
FragTrap( FragTrap const & src ); // copy constructor
~FragTrap(); // destructor
FragTrap(std::string name);
~FragTrap( void );
FragTrap & operator=( FragTrap const & rhs ); // assignement operator
void highFivesGuys();
private:
static const std::string _dName;
static const std::string _dClass;
static const int _dHit;
static const int _dEnergy;
static const int _dAttack;
static const int _dNumber;
};
#endif

View File

@@ -1,30 +1,59 @@
#include "ScavTrap.hpp"
/*********************************************
* CONSTRUCTORS
*********************************************/
ScavTrap::ScavTrap( std::string name ) : ClapTrap(name) {
_class = "ScavTrap";
_hit = 100;
_energy = 50;
_attack = 20;
std::cout << _class << " " << ScavTrap::_name << " created with number " << _number << "\n";
_class = _dClass;
_hit = _dHit;
_energy = _dEnergy;
_attack = _dAttack;
std::cout << _class << " " << _name << "-" << _number << " created\n";
return;
}
/*
* destructor
*/
ScavTrap::ScavTrap( ScavTrap const & src ) {
_class = _dClass;
*this = src;
_number = getTotalNumber();
std::cout << _class << " " << _name << "-" << _number << " copied from " << src._class << "-" << src._name << "-" << src._number << "\n";
return;
}
/*********************************************
* DESTRUCTORS
*********************************************/
ScavTrap::~ScavTrap( void ) {
std::cout << _class << " " << ScavTrap::_name << " destructed\n";
std::cout << _class << " " << _name << "-" << _number << " destructed\n";
return;
}
/*
* special capacity
*/
/*********************************************
* OPERATORS
*********************************************/
ScavTrap & ScavTrap::operator=( ScavTrap const & rhs ) {
ClapTrap::operator=(rhs);
return *this;
}
/*********************************************
* PUBLIC MEMBER FUNCTIONS
*********************************************/
void ScavTrap::guardGate() {
std::cout << _class << " " << ScavTrap::_name << " entered special mode Gate Keeper\n";
std::cout << _class << " " << _name << "-" << _number << " entered special mode Gate Keeper\n";
}
/*********************************************
* STATICS
*********************************************/
std::string const ScavTrap::_dName = "robot";
std::string const ScavTrap::_dClass = "ScavTrap";
int const ScavTrap::_dHit = 100;
int const ScavTrap::_dEnergy = 50;
int const ScavTrap::_dAttack = 20;

View File

@@ -9,11 +9,23 @@ class ScavTrap : public ClapTrap {
public:
ScavTrap(std::string name);
~ScavTrap();
ScavTrap( std::string name = ScavTrap::_dName );
ScavTrap( ScavTrap const & src ); // copy constructor
~ScavTrap(); // destructor
ScavTrap & operator=( ScavTrap const & rhs ); // assignement operator
void guardGate();
private:
static const std::string _dName;
static const std::string _dClass;
static const int _dHit;
static const int _dEnergy;
static const int _dAttack;
static const int _dNumber;
};
#endif

View File

@@ -1,24 +0,0 @@
#ifndef COLOR_H
# define COLOR_H
# define GRAY "\e[0;30m"
# define RED "\e[0;31m"
# define GREEN "\e[0;32m"
# define YELLOW "\e[0;33m"
# define BLUE "\e[0;34m"
# define PURPLE "\e[0;35m"
# define CYAN "\e[0;36m"
# define WHITE "\e[0;37m"
# define B_GRAY "\e[1;30m"
# define B_RED "\e[1;31m"
# define B_GREEN "\e[1;32m"
# define B_YELLOW "\e[1;33m"
# define B_BLUE "\e[1;34m"
# define B_PURPLE "\e[1;35m"
# define B_CYAN "\e[1;36m"
# define B_WHITE "\e[1;37m"
# define RESET "\e[0m"
#endif

View File

@@ -1,103 +1,35 @@
#include "ClapTrap.hpp"
#include "ScavTrap.hpp"
#include "FragTrap.hpp"
void goAttack(ClapTrap & robot1, ClapTrap & robot2) {
#include <iostream>
#include <sstream>
# define B_GRAY "\e[1;30m"
# define B_RED "\e[1;31m"
# define B_GREEN "\e[1;32m"
# define B_YELLOW "\e[1;33m"
# define B_BLUE "\e[1;34m"
# define B_PURPLE "\e[1;35m"
# define B_CYAN "\e[1;36m"
# define B_WHITE "\e[1;37m"
# define RESET "\e[0m"
# define COLOR1 B_YELLOW
template < typename U, typename V >
void goAttack(U & robot1, V & robot2) {
std::stringstream ss;
std::string num;
ss << robot2.getNumber();
ss >> num;
std::cout << ".";
robot1.attack(robot2.getName());
robot1.attack(robot2.getName() + "-" + num);
std::cout << " ";
robot2.takeDamage(robot1.getAttack());
std::cout << " ";
robot2.beRepaired(robot1.getAttack());
}
void goAttack(ClapTrap & robot1, ScavTrap & robot2) {
std::cout << ".";
robot1.attack(robot2.getName());
std::cout << " ";
robot2.takeDamage(robot1.getAttack());
std::cout << " ";
robot2.beRepaired(robot1.getAttack());
}
void goAttack(ClapTrap & robot1, FragTrap & robot2) {
std::cout << ".";
robot1.attack(robot2.getName());
std::cout << " ";
robot2.takeDamage(robot1.getAttack());
std::cout << " ";
robot2.beRepaired(robot1.getAttack());
}
void goAttack(ScavTrap & robot1, ScavTrap & robot2) {
std::cout << ".";
robot1.attack(robot2.getName());
std::cout << " ";
robot2.takeDamage(robot1.getAttack());
std::cout << " ";
robot2.beRepaired(robot1.getAttack());
}
void goAttack(ScavTrap & robot1, ClapTrap & robot2) {
std::cout << ".";
robot1.attack(robot2.getName());
std::cout << " ";
robot2.takeDamage(robot1.getAttack());
std::cout << " ";
robot2.beRepaired(robot1.getAttack());
}
void goAttack(ScavTrap & robot1, FragTrap & robot2) {
std::cout << ".";
robot1.attack(robot2.getName());
std::cout << " ";
robot2.takeDamage(robot1.getAttack());
std::cout << " ";
robot2.beRepaired(robot1.getAttack());
}
void goAttack(FragTrap & robot1, FragTrap & robot2) {
std::cout << ".";
robot1.attack(robot2.getName());
std::cout << " ";
robot2.takeDamage(robot1.getAttack());
std::cout << " ";
robot2.beRepaired(robot1.getAttack());
}
void goAttack(FragTrap & robot1, ClapTrap & robot2) {
std::cout << ".";
robot1.attack(robot2.getName());
std::cout << " ";
robot2.takeDamage(robot1.getAttack());
std::cout << " ";
robot2.beRepaired(robot1.getAttack());
}
void goAttack(FragTrap & robot1, ScavTrap & robot2) {
std::cout << ".";
robot1.attack(robot2.getName());
std::cout << " ";
robot2.takeDamage(robot1.getAttack());
std::cout << " ";
robot2.beRepaired(robot1.getAttack());
}
int main() {

Binary file not shown.