Beispiel #1
0
        /// <summary>
        /// Used to turn the robot
        /// </summary>
        /// <param name="direction">Used to determine if the robot should turn left or right</param>
        /// <returns></returns>
        public string ChangeDirection(Enum.Direction direction)
        {
            int offset = direction.Equals(Enum.Direction.LEFT) ? 3 : 1;

            orientation = (Enum.Orientation)(((int)orientation + offset) % 4);

            return(string.Empty);
        }
Beispiel #2
0
        /// <summary>
        /// Used to place the robot on the table
        /// </summary>
        /// <param name="x">The X coordinate</param>
        /// <param name="y">The Y coordinate</param>
        /// <param name="o">The initial orientation for the robot</param>
        /// <returns>Empty string if robot successfully placed, otherwise an error message</returns>
        public string Place(int x, int y, Enum.Orientation o)
        {
            string result = string.Empty;

            if (MoveIsValid(x, y))
            {
                xPosition   = x;
                yPosition   = y;
                orientation = o;
            }
            else
            {
                result = Message.OUT_OF_BOUNDS_MESSAGE;
            }

            return(result);
        }