Esempio n. 1
0
        public static List <Object> RoverMovement(string instruction)
        {
            List <Object> list      = new List <Object>();
            string        returning = "";

            char[] stepByStepInstruction = instruction.ToCharArray();
            foreach (char fetchOneByOne in stepByStepInstruction)
            {
                if (fetchOneByOne == 'L')
                {
                    currentFacingDirection = currentFacingDirection.TurnLeft();
                }
                else if (fetchOneByOne == 'R')
                {
                    currentFacingDirection = currentFacingDirection.TurnRight();
                }
                else
                {
                    coordinate = currentFacingDirection.MoveForward(coordinate, map);
                }
            }
            list.Add(coordinate.X);
            list.Add(coordinate.Y);
            list.Add(currentFacingDirection.CharacterTellerOfDirectionOfEachClass());
            //returning = returning + coordinate.X + " " + coordinate.Y + " " + currentFacingDirection;
            return(list);
        }