From 4124f6d7d6b39639ac1f7dce32c05385765a2017 Mon Sep 17 00:00:00 2001 From: Lukasz Baldyga Date: Wed, 21 Oct 2020 13:39:00 +0100 Subject: [PATCH] Fixed error where the function would produce wrong commands --- .../SettingsAndHelperFunctions.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Advanced Software Engineering/Advanced Software Engineering/SettingsAndHelperFunctions.cs b/Advanced Software Engineering/Advanced Software Engineering/SettingsAndHelperFunctions.cs index 0bbe841..62eb2eb 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/SettingsAndHelperFunctions.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/SettingsAndHelperFunctions.cs @@ -76,6 +76,11 @@ namespace Advanced_Software_Engineering { return int.Parse(text); } + public static double ConvertToDouble(string text) { + text = Strip(text); + return double.Parse(text); + } + public static List StripStringArray(string[] array) { List newStringList = new List(); @@ -94,15 +99,15 @@ namespace Advanced_Software_Engineering { //split the command from the parameters string[] parameters = Strip(text).Split(new char[] { " "[0] }, 2); - //Check there is content + //There are parameters, make the command if (parameters.Length > 0) { //set command var string command = Strip(parameters[0]); commandAndParameters["command"] = new string[] { command }; } - //If there is nothing split after the first split, why bother doing anything? - else if (parameters.Length > 1) { + //There is at least one parameter + if (parameters.Length > 1) { //seperate all of the parameters by a comma parameters = parameters[1].Split(","[0]);