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)); }
public override string ToString() => $"{Point.X} {Point.Y} {Direction.ToString()[0]}";
public override string ToString() { return(Direction.ToString()); }
public override string ToString() => $"{_coordinate.X} {_coordinate.Y} {_direction.ToString()[0]}";
public string DeclareFinalDestination() { return($"{CoordinateX} {CoordinateY} {Direction.ToString()[0]}"); }