Private
Public Access
Changed IValue interface
This commit is contained in:
1 parent
fbbda5df3b
commit
9309b975a6
5 files changed
+24
-30
No files matched your search
@@ -1,9 +1,8 @@
|
|||||||
using System;
|
using System.Drawing;
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.Value {
|
namespace Advanced_Software_Engineering.Verbs.Value {
|
||||||
|
|
||||||
internal interface IValue {
|
public interface IValue {
|
||||||
|
|
||||||
string GetDescription();
|
string GetDescription();
|
||||||
|
|
||||||
@@ -15,7 +14,7 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
|||||||
|
|
||||||
Color ToColor();
|
Color ToColor();
|
||||||
|
|
||||||
Type GetOriginalType();
|
string GetOriginalType();
|
||||||
|
|
||||||
bool isInitialised();
|
bool isInitialised();
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-6
@@ -4,11 +4,10 @@ using System.Drawing;
|
|||||||
namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
|
namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
|
||||||
|
|
||||||
internal class BoolValue : IValue {
|
internal class BoolValue : IValue {
|
||||||
|
private bool initialised = false;
|
||||||
|
|
||||||
bool initialised = false;
|
private bool value;
|
||||||
|
private Type type = typeof(bool);
|
||||||
bool value;
|
|
||||||
Type type = typeof(bool);
|
|
||||||
|
|
||||||
public BoolValue(bool value) {
|
public BoolValue(bool value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
@@ -23,8 +22,8 @@ namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
|
|||||||
else return "an unset boolean value";
|
else return "an unset boolean value";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type GetOriginalType() {
|
public string GetOriginalType() {
|
||||||
return type;
|
return "bool";
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ToBool() {
|
public bool ToBool() {
|
||||||
|
|||||||
+5
-6
@@ -4,11 +4,10 @@ using System.Drawing;
|
|||||||
namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
|
namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
|
||||||
|
|
||||||
internal class ColorValue : IValue {
|
internal class ColorValue : IValue {
|
||||||
|
private bool initialised = false;
|
||||||
|
|
||||||
bool initialised = false;
|
private Color value;
|
||||||
|
private Type type = typeof(Color);
|
||||||
Color value;
|
|
||||||
Type type = typeof(Color);
|
|
||||||
|
|
||||||
public ColorValue(Color value) {
|
public ColorValue(Color value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
@@ -23,8 +22,8 @@ namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
|
|||||||
else return "An uninitialised color";
|
else return "An uninitialised color";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type GetOriginalType() {
|
public string GetOriginalType() {
|
||||||
return type;
|
return "color";
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ToBool() {
|
public bool ToBool() {
|
||||||
|
|||||||
+9
-10
@@ -4,14 +4,13 @@ using System.Drawing;
|
|||||||
namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
|
namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
|
||||||
|
|
||||||
internal class DoubleValue : IValue {
|
internal class DoubleValue : IValue {
|
||||||
|
private bool initialised = false;
|
||||||
|
|
||||||
bool initialised = false;
|
private bool colorValueCacheAvailable = false;
|
||||||
|
private Color colorValueCache;
|
||||||
|
|
||||||
bool colorValueCacheAvailable = false;
|
private double value;
|
||||||
Color colorValueCache;
|
private Type type = typeof(double);
|
||||||
|
|
||||||
double value;
|
|
||||||
Type type = typeof(double);
|
|
||||||
|
|
||||||
public DoubleValue(double value) {
|
public DoubleValue(double value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
@@ -21,8 +20,8 @@ namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
|
|||||||
return "an double value of " + value;
|
return "an double value of " + value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type GetOriginalType() {
|
public string GetOriginalType() {
|
||||||
return type;
|
return "double";
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ToBool() {
|
public bool ToBool() {
|
||||||
@@ -30,8 +29,8 @@ namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Color ToColor() {
|
public Color ToColor() {
|
||||||
if(!colorValueCacheAvailable) {
|
if (!colorValueCacheAvailable) {
|
||||||
int i = (int) Math.Round(value * 255);
|
int i = (int)Math.Round(value * 255);
|
||||||
i = Math.Max(255, i);
|
i = Math.Max(255, i);
|
||||||
colorValueCache = ValueHelper.IntsToColor(i, i, i);
|
colorValueCache = ValueHelper.IntsToColor(i, i, i);
|
||||||
colorValueCacheAvailable = true;
|
colorValueCacheAvailable = true;
|
||||||
|
|||||||
+2
-4
@@ -17,8 +17,6 @@ namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
|
|||||||
private bool colorValueCacheAvailable = false;
|
private bool colorValueCacheAvailable = false;
|
||||||
private Color colorValueCache;
|
private Color colorValueCache;
|
||||||
|
|
||||||
private Type type = typeof(int);
|
|
||||||
|
|
||||||
public IntValue(int value) {
|
public IntValue(int value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
@@ -27,8 +25,8 @@ namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
|
|||||||
return "an integer value of " + value;
|
return "an integer value of " + value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type GetOriginalType() {
|
public string GetOriginalType() {
|
||||||
return type;
|
return "int";
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ToBool() {
|
public bool ToBool() {
|
||||||
|
|||||||
Reference in new issue
Block a user