From 0711fcad6742c2bb43084835e4fd3be25b59b8bf Mon Sep 17 00:00:00 2001 From: Lukasz Baldyga Date: Thu, 26 Nov 2020 12:34:19 +0000 Subject: [PATCH] Added new entries to ValueFactory --- .../Verbs/Value/ValueFactory.cs | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/Advanced Software Engineering/Advanced Software Engineering/Verbs/Value/ValueFactory.cs b/Advanced Software Engineering/Advanced Software Engineering/Verbs/Value/ValueFactory.cs index 203378d..d58c0c5 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Verbs/Value/ValueFactory.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/Verbs/Value/ValueFactory.cs @@ -2,14 +2,16 @@ using System; namespace Advanced_Software_Engineering.Verbs.Value { - class ValueFactory { + + public class ValueFactory { + /// /// Creates a constant Value to be used later during execution /// /// Text representation of the value /// What type the value should be /// - 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); + } } -} +} \ No newline at end of file