示例#1
0
 public NasaMarsRover(int startingX, int startingY, RoverCardinalDirectionEnum startingHeading)
 {
     CurrentLocation = new MarsCoordinate()
     {
         X = startingX,
         Y = startingY
     };
     CurrentHeading = startingHeading;
 }
示例#2
0
        /// <summary>
        /// Turns the rover right by 90 degrees, without changing its coordinates. For example, if the rover is facing North, this method will cause it to face East.
        /// </summary>
        internal void TurnRoverRight()
        {
            switch (CurrentHeading)
            {
            case RoverCardinalDirectionEnum.North:
                CurrentHeading = RoverCardinalDirectionEnum.East;
                break;

            case RoverCardinalDirectionEnum.East:
                CurrentHeading = RoverCardinalDirectionEnum.South;
                break;

            case RoverCardinalDirectionEnum.South:
                CurrentHeading = RoverCardinalDirectionEnum.West;
                break;

            case RoverCardinalDirectionEnum.West:
                CurrentHeading = RoverCardinalDirectionEnum.North;
                break;
            }
        }
示例#3
0
 /// <summary>
 /// Converts the <see cref="RoverCardinalDirectionEnum"/> into a single char for text output.
 /// This method gets the first char of the ToString() and returns it.
 /// </summary>
 /// <param name="directionEnum"></param>
 /// <returns></returns>
 public static char ConvertCardinalDirectionToChar(this RoverCardinalDirectionEnum directionEnum)
 {
     //Grab the first char from the char array
     return(directionEnum.ToString().First());
 }