From e0ff2ab464890568410396b47e93499fb1f5bb13 Mon Sep 17 00:00:00 2001 From: Lukasz Baldyga Date: Fri, 27 Nov 2020 15:16:14 +0000 Subject: [PATCH] Added Variable Values --- .../Advanced Software Engineering.csproj | 7 ++-- .../Verbs/Value/ValueTypes/VariableValue.cs | 36 ++++++++++++------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/Advanced Software Engineering/Advanced Software Engineering/Advanced Software Engineering.csproj b/Advanced Software Engineering/Advanced Software Engineering/Advanced Software Engineering.csproj index 9b880e3..9a9ec55 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Advanced Software Engineering.csproj +++ b/Advanced Software Engineering/Advanced Software Engineering/Advanced Software Engineering.csproj @@ -89,7 +89,7 @@ - + @@ -100,6 +100,7 @@ + Form @@ -207,6 +208,8 @@ - + + + \ No newline at end of file diff --git a/Advanced Software Engineering/Advanced Software Engineering/Verbs/Value/ValueTypes/VariableValue.cs b/Advanced Software Engineering/Advanced Software Engineering/Verbs/Value/ValueTypes/VariableValue.cs index 03f4df3..7e832f1 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Verbs/Value/ValueTypes/VariableValue.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/Verbs/Value/ValueTypes/VariableValue.cs @@ -1,38 +1,48 @@ using System; -using System.Collections.Generic; using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes { - class VariableValue : IValue { + + public class VariableValue : IValue { + private Drawer drawer; + private string variableName; + + public VariableValue(Drawer drawer, string variableName) { + this.variableName = variableName; + if (!drawer.CheckVariableExists(variableName)) throw new Exception("Tried to access " + variableName + " before it was assigned. "); + this.drawer = drawer; + } + + private IValue get() { + return drawer.GetVariable(variableName); + } + public string GetDescription() { - throw new NotImplementedException(); + return get().GetDescription(); } public string GetOriginalType() { - throw new NotImplementedException(); + return get().GetOriginalType(); } public bool isInitialised() { - throw new NotImplementedException(); + return get().isInitialised(); } public bool ToBool() { - throw new NotImplementedException(); + return get().ToBool(); } public Color ToColor() { - throw new NotImplementedException(); + return get().ToColor(); } public double ToDouble() { - throw new NotImplementedException(); + return get().ToDouble(); } public int ToInt() { - throw new NotImplementedException(); + return get().ToInt(); } } -} +} \ No newline at end of file