Private
Public Access
Created IntValue
This commit is contained in:
1 parent
cbc4b3defe
commit
767c35361d
1 file changed
+38
-6
+38
-6
@@ -5,28 +5,60 @@ namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
|
||||
|
||||
internal class IntValue : IValue {
|
||||
|
||||
int value;
|
||||
|
||||
bool doubleValueCacheAvaiable = false;
|
||||
double doubleValueCache;
|
||||
|
||||
bool boolValueCacheAvailable = false;
|
||||
bool boolValueCache;
|
||||
|
||||
bool colorValueCacheAvailable = false;
|
||||
Color colorValueCache;
|
||||
|
||||
Type type = typeof(int);
|
||||
|
||||
public IntValue(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public string GetDescription() {
|
||||
throw new NotImplementedException();
|
||||
return "an integer value of " + value;
|
||||
}
|
||||
|
||||
public Type GetOriginalType() {
|
||||
throw new NotImplementedException();
|
||||
return type;
|
||||
}
|
||||
|
||||
public bool ToBool() {
|
||||
throw new NotImplementedException();
|
||||
if(!boolValueCacheAvailable) {
|
||||
boolValueCache = value <= 0;
|
||||
boolValueCacheAvailable = true;
|
||||
}
|
||||
|
||||
return boolValueCache;
|
||||
}
|
||||
|
||||
public Color ToColor() {
|
||||
throw new NotImplementedException();
|
||||
if(!colorValueCacheAvailable) {
|
||||
byte[] bytes = BitConverter.GetBytes(value);
|
||||
Array.Reverse(bytes);
|
||||
colorValueCache = ValueHelper.IntsToColor(bytes[1], bytes[2], bytes[3], bytes[0]);
|
||||
colorValueCacheAvailable = true;
|
||||
}
|
||||
return colorValueCache;
|
||||
}
|
||||
|
||||
public double ToDouble() {
|
||||
throw new NotImplementedException();
|
||||
if (!doubleValueCacheAvaiable) {
|
||||
doubleValueCache = value;
|
||||
doubleValueCacheAvaiable = true;
|
||||
}
|
||||
return doubleValueCache;
|
||||
}
|
||||
|
||||
public int ToInt() {
|
||||
throw new NotImplementedException();
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user