#include "OutDatedZone.h"
#include "DebugAI.h"

OutDatedZone::OutDatedZone(void){
	name = OUT_DATED_ZONE;
	begin = 1;
	end = 5;
}

OutDatedZone::~OutDatedZone(void)
{
}

OutDatedZone::OutDatedZone(Fresh* aFuzzyNumber){
	fuzzyNumber = aFuzzyNumber;
	fuzzyNumber->addFV(this);
	name = OUT_DATED_ZONE;
	begin = 1;
	end = 5;
}
void OutDatedZone::update(){
	if (this->getFuzzyNumberValue()>= 0 && this->getFuzzyNumberValue()<=begin){
		setValue(0);
	}
	if (this->getFuzzyNumberValue()>= end){
		setValue(1);
	}
	if (this->getFuzzyNumberValue()<0){
		//If the execution go here they must have a problem.
		setValue(-1);
	}
	if (this->getFuzzyNumberValue()>= begin && this->getFuzzyNumberValue()<end){
		setValue((this->getFuzzyNumberValue() * (1/(end-begin))) - begin/(end-begin));
	}
	DebugAI::trace('v', toString());
}

void OutDatedZone::setBegin(float aBegin){
	begin = aBegin;
}

void OutDatedZone::setEnd(float aEnd){
	end = aEnd;
}