static void implementInput(string _feederCoords, string _robotCoords, string _crateString, string _instructions, List <string> _testOutput = null, bool testMode = false) { int[] feederCoords = Array.ConvertAll(_feederCoords.Split(" "), s => int.Parse(s)); Feeder feeder = new Feeder(feederCoords[0], feederCoords[1]); int[] robotCoords = Array.ConvertAll(_robotCoords.Split(" "), s => int.Parse(s)); Robot robot = new Robot(robotCoords[0], robotCoords[1]); string[] crateStrings = _crateString.Split(","); List <Crate> crates = new List <Crate>(); foreach (string crateString in crateStrings) { int[] crateInts = Array.ConvertAll(crateString.Trim().Split(" "), s => int.Parse(s)); Crate crate = new Crate(crateInts[0], crateInts[1], crateInts[2]); crates.Add(crate); } string instructions = _instructions; PickList pickList = new PickList(feeder, robot, crates, instructions); pickList.Execute(); // Present output bool testPassed = true; if (pickList.Output.Count == 0) { throw new System.ArgumentException("Insufficient picklist output"); } int i = 0; foreach (string pickListOutput in pickList.Output) { Console.WriteLine(pickListOutput); if (testMode == true) { string testOuput = _testOutput[i]; if (testOuput != pickListOutput) { testPassed = false; } } i += 1; } if (testMode == true) { if (testPassed == true) { Console.WriteLine("Test passed"); } else { Console.WriteLine("Test failed, expected: "); foreach (string testOuput in _testOutput) { Console.WriteLine(testOuput); } } } }
public PickList(Feeder _feeder, Robot _robot, List <Crate> _crates, string _instructions) { feeder = _feeder; robot = _robot; crates = _crates; instructions = _instructions; output = new List <string>(); }