Exemplo n.º 1
0
        public void SendCommand(IEnumerable <string> input)
        {
            if (!input.Any())
            {
                throw new InvalidCommandException("Please provide valid command and position.");
            }

            var rovers        = new List <Robot>();
            var roverCommands = ParseRobotCommands.From(input);

            foreach (var roverCommand in roverCommands)
            {
                var robot = new Robot(roverCommand.StartingPosition, _output);
                foreach (var instruction in roverCommand.Instructions)
                {
                    robot.Send(instruction);
                }

                rovers.Add(robot);
                _output.Write(robot.CurrentPosition.ToString());
            }
        }