Exemplo n.º 1
0
        public static void Go(int x, int y, int direction, Command[] commandList)
        {
            foreach (Command command in commandList)
            {
                switch (command)
                {
                case Command.L:
                    direction++;
                    if (direction == 5)
                    {
                        direction = 1;
                    }
                    break;

                case Command.M:
                    switch (direction)
                    {
                    case 1:
                        y++;
                        break;

                    case 2:
                        x--;
                        break;

                    case 3:
                        y--;
                        break;

                    case 4:
                        x++;
                        break;

                    default:
                        break;
                    }
                    break;

                case Command.R:
                    direction--;
                    if (direction == 0)
                    {
                        direction = 4;
                    }
                    break;

                default:
                    break;
                }
            }
            Direction position = (Direction)direction;

            Console.WriteLine(x.ToString() + " " + y.ToString() + " " + position.ToString().Substring(0, 1));
        }
Exemplo n.º 2
0
 public override string ToString()
 => $"{Point.X} {Point.Y} {Direction.ToString()[0]}";
Exemplo n.º 3
0
 public override string ToString()
 {
     return(Direction.ToString());
 }
Exemplo n.º 4
0
 public override string ToString() => $"{_coordinate.X} {_coordinate.Y} {_direction.ToString()[0]}";
Exemplo n.º 5
0
 public string DeclareFinalDestination()
 {
     return($"{CoordinateX} {CoordinateY} {Direction.ToString()[0]}");
 }