Private
Public Access
Added new entries to ValueFactory
This commit is contained in:
1 parent
5663aca3ea
commit
0711fcad67
1 file changed
+23
-5
+23
-5
@@ -2,14 +2,16 @@
|
||||
using System;
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.Value {
|
||||
class ValueFactory {
|
||||
|
||||
public class ValueFactory {
|
||||
|
||||
/// <summary>
|
||||
/// Creates a constant Value to be used later during execution
|
||||
/// </summary>
|
||||
/// <param name="value">Text representation of the value</param>
|
||||
/// <param name="type">What type the value should be</param>
|
||||
/// <returns></returns>
|
||||
public IValue CreateValue(string value, string type) {
|
||||
public static IValue CreateValue(string value, string type) {
|
||||
switch (type) {
|
||||
case "int":
|
||||
return new IntValue(ValueHelper.ConvertToInt(value));
|
||||
@@ -17,14 +19,30 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
||||
case "double":
|
||||
return new DoubleValue(ValueHelper.ConvertToDouble(value));
|
||||
|
||||
case "color":
|
||||
return new ColorValue(ValueHelper.TextToColor(value));
|
||||
|
||||
case "bool":
|
||||
return new BoolValue(ValueHelper.ConvertToBool(value));
|
||||
|
||||
case "expression":
|
||||
return new Exception(ValueHelper.ConvertToExpression(value));
|
||||
|
||||
default:
|
||||
throw new Exception("Unknown expected type: " + type.ToString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static IValue CreateValue(bool b) {
|
||||
return new BoolValue(b);
|
||||
}
|
||||
|
||||
public static IValue CreateValue(double d) {
|
||||
return new DoubleValue(d);
|
||||
}
|
||||
|
||||
|
||||
public static IValue CreateValue(int i) {
|
||||
return new IntValue(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user