d03 ex01 refondus avec meilleurs gestion de la classe de base
This commit is contained in:
59
d03/jodufour/private/class/ClapTrap.hpp
Normal file
59
d03/jodufour/private/class/ClapTrap.hpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef CLAPTRAP_HPP
|
||||
# define CLAPTRAP_HPP
|
||||
|
||||
# include <iostream>
|
||||
|
||||
# ifndef DEBUG
|
||||
# define DEBUG 0
|
||||
# endif
|
||||
|
||||
class ClapTrap
|
||||
{
|
||||
private:
|
||||
// Attributes
|
||||
static std::string const _defaultName;
|
||||
static unsigned int const _defaultHitPoints;
|
||||
static unsigned int const _defaultEnergyPoints;
|
||||
static unsigned int const _defaultAttackDamages;
|
||||
|
||||
protected:
|
||||
// Attributes
|
||||
std::string _name;
|
||||
unsigned int _hitPoints;
|
||||
unsigned int _energyPoints;
|
||||
unsigned int _attackDamages;
|
||||
|
||||
// Constructors
|
||||
ClapTrap(
|
||||
std::string const &name,
|
||||
unsigned int const hitPoints,
|
||||
unsigned int const energyPoints,
|
||||
unsigned int const attackDamages);
|
||||
|
||||
public:
|
||||
// Constructors
|
||||
ClapTrap(std::string const &name = ClapTrap::_defaultName);
|
||||
ClapTrap(ClapTrap const &src);
|
||||
|
||||
// Destructors
|
||||
virtual ~ClapTrap(void);
|
||||
|
||||
// Accessors
|
||||
std::string const &getName(void) const;
|
||||
|
||||
unsigned int getHitPoints(void) const;
|
||||
unsigned int getEnergyPoints(void) const;
|
||||
unsigned int getAttackDamages(void) const;
|
||||
|
||||
// Member functions
|
||||
virtual void attack(std::string const &target);
|
||||
void beRepaired(unsigned int const amount);
|
||||
void takeDamage(unsigned int const amount);
|
||||
|
||||
// Operators
|
||||
ClapTrap &operator=(ClapTrap const &rhs);
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &o, ClapTrap const &rhs);
|
||||
|
||||
#endif
|
||||
39
d03/jodufour/private/class/ScavTrap.hpp
Normal file
39
d03/jodufour/private/class/ScavTrap.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef SCAVTRAP_HPP
|
||||
# define SCAVTRAP_HPP
|
||||
|
||||
# include "ClapTrap.hpp"
|
||||
|
||||
# ifndef DEBUG
|
||||
# define DEBUG 0
|
||||
# endif
|
||||
|
||||
class ScavTrap : public ClapTrap
|
||||
{
|
||||
private:
|
||||
// Attributes
|
||||
bool _activeMode;
|
||||
|
||||
static std::string const _defaultName;
|
||||
static unsigned int const _defaultHitPoints;
|
||||
static unsigned int const _defaultEnergyPoints;
|
||||
static unsigned int const _defaultAttackDamages;
|
||||
|
||||
public:
|
||||
// Constructors
|
||||
ScavTrap(std::string const &name = ScavTrap::_defaultName);
|
||||
ScavTrap(ScavTrap const &src);
|
||||
|
||||
// Destructors
|
||||
virtual ~ScavTrap(void);
|
||||
|
||||
// Member functions
|
||||
virtual void attack(std::string const &target);
|
||||
void guardGate(void);
|
||||
|
||||
// Operators
|
||||
ScavTrap &operator=(ScavTrap const &rhs);
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &o, ScavTrap const &rhs);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user