diff --git a/Advanced Software Engineering/Advanced Software Engineering/Verbs/Flow/MethodChunk.cs b/Advanced Software Engineering/Advanced Software Engineering/Verbs/Flow/MethodChunk.cs index 5cf8afe..717e26d 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Verbs/Flow/MethodChunk.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/Verbs/Flow/MethodChunk.cs @@ -3,7 +3,9 @@ using System.Collections.Generic; using System.Drawing; namespace Advanced_Software_Engineering.Verbs.Flow { - + /// + /// The method chunk class + /// public class MethodChunk : VerbChunk, IVerb, IValue { private readonly ValueStorage valueStorage; private readonly DeclareVariable[] variables; @@ -11,25 +13,38 @@ namespace Advanced_Software_Engineering.Verbs.Flow { private bool init = false; private IValue result; + /// + /// The method chunk + /// + /// The ValueStorage for increasing and decreasing the stack + /// The variables to pass into the method public MethodChunk(ValueStorage valueStorage, DeclareVariable[] variables) : base() { this.valueStorage = valueStorage; this.variables = variables; } + /// + /// Gets all of the variable names + /// + /// The names of all the variables public List GetVariableNames() { List VariableNames = new List(); foreach (DeclareVariable variable in variables) VariableNames.Add(variable.GetName()); return VariableNames; } - public DeclareVariable[] GetVariables() { - return variables; - } - + /// + /// MUST BE CALLED. This method is really important for setting the updated values into the method's stack. + /// + /// The new values of the method public void SetVariableValues(UpdateVariable[] updateVariables) { this.updateVariables = updateVariables; } + /// + /// This method allows the method chunk to replicate itself before being ran. Essential for recursion. + /// + /// A method chunk with the exact same values and verbs public MethodChunk DuplicateForExecution() { MethodChunk method = new MethodChunk(valueStorage, variables); method.SetVariableValues(updateVariables); @@ -39,6 +54,9 @@ namespace Advanced_Software_Engineering.Verbs.Flow { return method; } + /// + /// Executes the method chunk. + /// public new void ExecuteVerb() { init = false; result = null; @@ -60,34 +78,66 @@ namespace Advanced_Software_Engineering.Verbs.Flow { valueStorage.DecreaseStack(); } + /// + /// Gets a result from the method. (Experimental) + /// + /// the result public IValue GetResult() { return result; } + /// + /// Clones the result of the method (Experimental) + /// + /// public IValue Clone() { return GetResult().Clone(); } + /// + /// Gets the original type of the result of the method (Experimental) + /// + /// public string GetOriginalType() { return GetResult().GetOriginalType(); } + /// + /// Checks if the result is initilised (Experimental) + /// + /// public bool isInitialised() { return init; } + /// + /// Converts the result to boolean (Experimental) + /// + /// boolean representation of the result public bool ToBool() { return GetResult().ToBool(); } + /// + /// Converts the result to color (Experimental) + /// + /// color representation of the result public Color ToColor() { return GetResult().ToColor(); } + /// + /// Converts the result to double (Experimental) + /// + /// double representation of the result public double ToDouble() { return GetResult().ToDouble(); } + /// + /// Converts the result to integer (Experimental) + /// + /// integer representation of the result public int ToInt() { return GetResult().ToInt(); }