Избавиться от дублирования кода

День добрый помогите избавиться от дублирования кода, понимания в этом совершенно нету никакого потому что начинаю только осваивать язык.

namespace Mazes
{
    public static class EmptyMazeTask
    {
        public static void MoveOut(Robot robot, int width, int height)
        {
            MoveRight(robot, width - 2);
            MoveDown(robot, height - 2);
        }

        public static void MoveRight(Robot r, int steps)
        {
            for (int i = 1; i < steps; i++)
                r.MoveTo(Direction.Right);
        }

        public static void MoveDown(Robot r, int steps)
        {
            for (int i = 1; i < steps; i++)
                r.MoveTo(Direction.Down);
        }
    }
}

Ответы (1 шт):

Автор решения: aepot

Я бы сделал как-то так

public static void Move(Robot r, Direction direction, int steps)
{
    for (int i = 1; i < steps; i++)
        r.MoveTo(direction);
}
Move(robot, Direction.Right, width - 2);
Move(robot, Direction.Down, height - 2);
→ Ссылка