blob: d61d77cea41fbce4667f32fce5c2f8091020f440 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include "stdafx.h"
#include "RangedAttribute.h"
RangedAttribute::RangedAttribute(eATTRIBUTE_ID id, double defaultValue, double minValue, double maxValue) : BaseAttribute(id, defaultValue)
{
this->minValue = minValue;
this->maxValue = maxValue;
//if (minValue > maxValue) throw new IllegalArgumentException("Minimum value cannot be bigger than maximum value!");
//if (defaultValue < minValue) throw new IllegalArgumentException("Default value cannot be lower than minimum value!");
//if (defaultValue > maxValue) throw new IllegalArgumentException("Default value cannot be bigger than maximum value!");
}
double RangedAttribute::getMinValue()
{
return minValue;
}
double RangedAttribute::getMaxValue()
{
return maxValue;
}
double RangedAttribute::sanitizeValue(double value)
{
if (value < minValue) value = minValue;
if (value > maxValue) value = maxValue;
return value;
}
|