Exemplo n.º 1
0
        private void ParseLawnPositionLine(string positionLine, ref MoverData moverData)
        {
            var match     = Regex.Match(positionLine, CoordinatesPattern);
            var x         = int.Parse(match.Groups[1].Value);
            var y         = int.Parse(match.Groups[2].Value);
            var direction = (Direction)Enum.Parse(typeof(Direction), match.Groups[3].Value);

            moverData.StartCoordinates = new Coordinates(x, y, direction);
        }
Exemplo n.º 2
0
        private void ParseMoversData(ref InputData inputData)
        {
            var isLawnPositionLine = true;
            var moverData          = new MoverData();

            string line;

            while (!string.IsNullOrEmpty(line = Console.ReadLine()))
            {
                if (isLawnPositionLine)
                {
                    ParseLawnPositionLine(line, ref moverData);
                    isLawnPositionLine = false;
                }
                else
                {
                    ParseInstructionsLine(line, ref moverData);
                    inputData.MowerData.Add(moverData);
                    moverData          = new MoverData();
                    isLawnPositionLine = true;
                }
            }
        }
Exemplo n.º 3
0
        private void ParseInstructionsLine(string instructionLine, ref MoverData moverData)
        {
            var match = Regex.Match(instructionLine, InstructionsPattern);

            moverData.Instructions = match.Groups[1].Value;
        }