예제 #1
0
        public MapVectorOnSurface MoveForward(MapVectorOnSurface Map)
        {
            switch (Map.Current_Direction)
            {
            case Direction.East: Map.X_Coordinate++; break;

            case Direction.North: Map.Y_Coordinate++; break;

            case Direction.West: Map.X_Coordinate--; break;

            case Direction.South: Map.Y_Coordinate--; break;

            default: Map.Current_Direction = Direction.Wrong_Direction; break;
            }
            return(Map);
        }
예제 #2
0
        public MapVectorOnSurface TurnLeft(MapVectorOnSurface Map)
        {
            switch (Map.Current_Direction)
            {
            case Direction.East: Map.Current_Direction = Direction.North; break;

            case Direction.North: Map.Current_Direction = Direction.West; break;

            case Direction.West: Map.Current_Direction = Direction.South; break;

            case Direction.South: Map.Current_Direction = Direction.East; break;

            default: Map.Current_Direction = Direction.Wrong_Direction; break;
            }
            return(Map);
        }
예제 #3
0
        public MapVectorOnSurface FindRoverFinlPositionAndDirection(MapVectorOnSurface Map, string input)
        {
            RoverPosition Position = new RoverPosition(Map.X_Coordinate, Map.Y_Coordinate, (char)Map.Current_Direction);

            for (int i = 0; i < input.Length; i++)
            {
                switch (input[i])
                {
                case 'L': Action.TurnLeft(Position.Map); break;

                case 'R': Action.TurnRight(Position.Map); break;

                case 'F': Action.MoveForward(Position.Map); break;
                }
            }
            return(Position.Map);
        }