Commit f48dc69a authored by Alexis Lebis's avatar Alexis Lebis

competency builder ok

parent 34f2f7e2
{
"files.associations": {
"array": "cpp",
"atomic": "cpp",
"strstream": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"list": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"map": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"set": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"cfenv": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp",
"valarray": "cpp"
}
}
\ No newline at end of file
......@@ -6,6 +6,7 @@
#include <queenEval.h>
#include <model/magnitude.h>
#include <model/competency.h>
#include <model/exception/magnitudeException.h>
int main(int argc, char* argv[]){
......
#include "competency.h"
#include "magnitude.h"
#include "exception/magnitudeException.h"
// === FACTORY
Competency Competency::build(Magnitude & m, std::string name = "")
{
int id = Competency::assignID();
if(name.empty())
name = "Competency#"+id;
return Competency(id, m, name);
}
Competency Competency::build(double d = 0, std::string name = "")
{
int id = Competency::assignID();
if(name.empty())
name = "Competency#"+id;
try
{
Magnitude m = Magnitude::build(d);
return Competency(id, m, name);
}
catch(MagnitudeException & e)
{
e.getMagnitude().rebase();
Magnitude m(e.getMagnitude());
return Competency(id, m, name);
}
}
// === CONSTRUCTOR
Competency::Competency(int id, Magnitude m, std::string s)
: _id(id), _m(m), _name(s)
{
}
// === STATIC
int Competency::assignID()
{
return ++Competency::COMPETENCY_COUNTER;
}
// === FUNCTION
/// @TODO
void Competency::evolveTowards(Magnitude & m)
{
}
/// @TODO
void Competency::evolveTowards(double d)
{
}
\ No newline at end of file
......@@ -15,14 +15,49 @@
class Competency
{
private:
Magnitude m;
std::string name;
int id;
Magnitude & _m;
std::string _name;
int _id;
//Constructor
Competency(int, Magnitude, std::string);
//STATIC
static int COMPETENCY_COUNTER;
static int assignID();
public:
Competency();
static Competency build(Magnitude &, std::string);
static Competency build(double, std::string);
// === FUNCTION
/** evolveTowards allows the competency to increase or decrease according to the value passed in parameter (either in Magnitude._value or double). It represents the competency evolving towards a specfic state, here represented by this->_m.value() + m.value().
* Use it instead of manipuling directly a Magnitude, since it'll handle MagnitudeException
*
* @throw CompetencyEvolvingException
*/
void evolveTowards(Magnitude & m);
/** evolveTowards allows the competency to increase or decrease according to the value passed in parameter (either in Magnitude._value or double). It represents the competency evolving towards a specfic state, here represented by this->_m.value() + d.
* Use it instead of manipuling directly a Magnitude, since it'll handle MagnitudeException
*
* @throw CompetencyEvolvingException
*/
void evolveTowards(double d);
// === GETTER
///Retrieves the magnitude/mastery value of the competency
const double competencyValue() const;
///Retrieves the magnitude of the compentecy
const Magnitude c_magnitude() const {return this->_m;}
Magnitude & magnitude(){return this->_m;}
///Retrieves the name of the competency
const std::string c_name() const {return this->_name;}
std::string & name() {return this->_name;}
const int id() const {return this->_id;}
// === SETTER
void setMagnitude(Magnitude & m){this->_m = m;};
};
int Competency::COMPETENCY_COUNTER = 0;
#endif // SRC_COMPETENCY_H_
\ No newline at end of file
......@@ -33,6 +33,9 @@ Magnitude::Magnitude(const Magnitude & m)
// === OPERATOR
/**
* @throw MagnitudeException Throw a MagnitudeException if the new value is > 1 or < 0. Note that the this->_value IS set (thus you can use this->rebase() to put _value in good range)
*/
Magnitude & Magnitude::operator+=(const double d)
{
this->_value+=d;
......@@ -41,6 +44,9 @@ Magnitude & Magnitude::operator+=(const double d)
return *this;
}
/**
* @throw MagnitudeException Throw a MagnitudeException if the new value is > 1 or < 0. Note that the this->_value IS set (thus you can use this->rebase() to put _value in good range)
*/
Magnitude & Magnitude::operator+=(const Magnitude & m)
{
this->_value += m._value;
......@@ -49,6 +55,9 @@ Magnitude & Magnitude::operator+=(const Magnitude & m)
return *this;
}
/**
* @throw MagnitudeException Throw a MagnitudeException if the new value is > 1 or < 0. You can catch the new magnitude causing the exception with magnitudeException.getMagnitude() (and thus perform the desired action, like a rebase)
*/
Magnitude operator+(const Magnitude & m, const Magnitude & n)
{
Magnitude mag(m);
......@@ -56,6 +65,9 @@ Magnitude operator+(const Magnitude & m, const Magnitude & n)
return mag;
}
/**
* @throw MagnitudeException Throw a MagnitudeException if the new value is > 1 or < 0. You can catch the new magnitude causing the exception with magnitudeException.getMagnitude() (and thus perform the desired action, like a rebase)
*/
Magnitude operator+(const Magnitude & m, const double d)
{
Magnitude mag(m);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment