示例#1
0
        public PositionMower MoveForward(Lawn lawn)
        {
            PositionMower futurePositionMower = PredictPosition();

            return(lawn.CanMoveInThisPosition(futurePositionMower)
                ? futurePositionMower
                : this);
        }
示例#2
0
        public string Run(string sequenceChar)
        {
            //TODO : check that sequence char is valid
            string[] splittedInput = ReadLines(sequenceChar);
            Dictionary <PositionMower, Command[]> commandsOnMowers = SequenceCharParser.ParseCommandOnMower(splittedInput);

            Lawn lawn = SequenceCharParser.ParseLawn(splittedInput[0], commandsOnMowers.Keys.ToArray());

            IEnumerable <PositionMower> newPositionMowers = ApplyCommands(commandsOnMowers, lawn);

            return(BuildOutputPosition(newPositionMowers));
        }
示例#3
0
 private static IEnumerable <PositionMower> ApplyCommands(Dictionary <PositionMower, Command[]> commandsOnMowers, Lawn lawn)
 {
     foreach (PositionMower positionMower in commandsOnMowers.Keys)
     {
         yield return(commandsOnMowers[positionMower].Aggregate(positionMower, lawn.ApplyCommand));
     }
 }