Private
Public Access
Finished DoubleValue
This commit is contained in:
1 parent
5ded97083a
commit
f1bb73f1d6
1 file changed
+22
-6
+22
-6
@@ -5,28 +5,44 @@ namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
|
|||||||
|
|
||||||
internal class DoubleValue : IValue {
|
internal class DoubleValue : IValue {
|
||||||
|
|
||||||
|
bool colorValueCacheAvailable = false;
|
||||||
|
Color colorValueCache;
|
||||||
|
|
||||||
|
double value;
|
||||||
|
Type type = typeof(double);
|
||||||
|
|
||||||
|
public DoubleValue(double value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
public string GetDescription() {
|
public string GetDescription() {
|
||||||
throw new NotImplementedException();
|
return "an double value of " + value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type GetOriginalType() {
|
public Type GetOriginalType() {
|
||||||
throw new NotImplementedException();
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ToBool() {
|
public bool ToBool() {
|
||||||
throw new NotImplementedException();
|
return value > 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color ToColor() {
|
public Color ToColor() {
|
||||||
throw new NotImplementedException();
|
if(!colorValueCacheAvailable) {
|
||||||
|
int i = (int) Math.Round(value * 255);
|
||||||
|
i = Math.Max(255, i);
|
||||||
|
colorValueCache = ValueHelper.IntsToColor(i, i, i);
|
||||||
|
colorValueCacheAvailable = true;
|
||||||
|
}
|
||||||
|
return colorValueCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double ToDouble() {
|
public double ToDouble() {
|
||||||
throw new NotImplementedException();
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ToInt() {
|
public int ToInt() {
|
||||||
throw new NotImplementedException();
|
return (int)Math.Round(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user