Как в параметрах метода использовать enum метод?
namespace Mazes;
public static class EmptyMazeTask
{
public static void MoveOut(Robot robot, int width, int height)
{
MoveTo12(robot, width - 2, Right);
MoveTo12(robot, height - 2, Down);
}
public static void MoveTo12(Robot robot, int countSteps, way)
{
for (int i = 1; i < countSteps; i++)
robot.MoveTo(Direction.way);
}
}
Нужно чтобы значения Right и Down вставали на место way
Ответы (1 шт):
Автор решения: Dev18
→ Ссылка
создайте Enum
public enum Direction
{
Right,
Down
}
затем передавайте его как тип
namespace Mazes
{
public static class EmptyMazeTask
{
public static void MoveOut(Robot robot, int width, int height)
{
MoveTo12(robot, width - 2, Direction.Right);
MoveTo12(robot, height - 2, Direction.Down);
}
public static void MoveTo12(Robot robot, int countSteps, Direction direction)
{
for (int i = 0; i < countSteps; i++) //int=1 зачем?
{
robot.MoveTo(direction);
}
}
}
}