Commit 0027fd76 authored by Alexis Lebis's avatar Alexis Lebis

Magnitude defined + qucik test

parent ffbd04bb
......@@ -5,8 +5,14 @@
#include <queenCrossover.h>
#include <queenEval.h>
#include <model/magnitude.h>
int main(int argc, char* argv[]){
Magnitude * m = Magnitude::build(-10.0);
std::cout << "Magnitude" << m->value() << std::endl;
//Define a QUEEN -> 1 line
QUEEN s1;
......
......@@ -2,7 +2,8 @@
#define SRC_COMPETENCY_H_
#include <string>
#include <magnitude.h>
#include "magnitude.h"
/**
* Represents the notion of a competency (a.k.a. "non operationalisable" skill).
......
......@@ -3,7 +3,7 @@
#include <vector>
#include <competency.h>
#include "competency.h"
/**
* Represents a course in an academic structure.
......
#ifndef SRC_EXCEPTION_MAGNITUDE_EXCEPTION_H_
#define SRC_EXCEPTION_MAGNITUDE_EXCEPTION_H_
#include <exception>
#include <string>
class MagnitudeException : public std::exception
{
private:
double _triedValue;
std::string _phrase;
public:
MagnitudeException(double v) throw()
: _triedValue(v)
{
this->_phrase = "Magnitude Exception: value (" + std::to_string(v) + ") is out of bound [0;1].";
}
virtual const char* what() const throw()
{
return _phrase.c_str();
}
virtual ~MagnitudeException() throw()
{}
};
#endif // SRC_EXCEPTION_MAGNITUDE_EXCEPTION_H_
\ No newline at end of file
#include "magnitude.h"
#include "exception/magnitudeException.h"
// === FACTORY
Magnitude* Magnitude::build(double value = 0)
{
bool isInRange = !(_inRange(value));
if( !isInRange )
throw MagnitudeException(value);
else
return new Magnitude(value);
}
// === CONSTRUCTOR
Magnitude::Magnitude()
{
}
Magnitude::Magnitude(double d)
{
this->_value=d;
}
// === FUNCTION
/** Checks if the value v is in [0;1]. If yes, return 0. Else, if v < 0 return -1, 1 otherwise
*/
const int Magnitude::_inRange(double v)
{
return v < 0 ? -1 : v > 1 ? 1 : 0;
}
const double Magnitude::value(){return this->_value;}
/** Set the magnitude value of a competency. Indicates whether or not there is an overflow in
* the given v value (and that it has been automatically corrected)
*/
bool Magnitude::set(double v)
{
int isInRange = _inRange(v);
switch (isInRange)
{
case -1:
this->_value = 0;
break;
case 1:
this->_value = 1;
break;
default:
this->_value = v;
break;
}
return !isInRange;
}
\ No newline at end of file
......@@ -8,10 +8,17 @@
class Magnitude
{
private:
double value = 0;
double _value = 0;
//Constructor
Magnitude();
Magnitude(double);
// function
static const int _inRange(double);
public:
Magnitude();
static Magnitude* build(double); //factory
//GETTER
const double value();
......
......@@ -3,7 +3,7 @@
#include <vector>
#include <competency.h>
#include "competency.h"
/**
* A profession is a job sought by a student.
......
#ifndef SRC_SCALE_MAPI_H_
#define SRC_SCALE_MAPI_H_
#include <scale.h>
#include "scale.h"
class MAPIScale : public Scale
{
......
#ifndef SRC_SCALE_SCALE_H_
#define SRC_SCALE_SCALE_H_
#include <scaleValue.h>
#include "scaleValue.h"
/** Represent a competency scale used by academic to assert competency level of a student.
*
......
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