public override void Execute(IRobot robot, ITableTop tableTop) { switch (robot.DirectionFacing) { case Direction.East: if (robot.X + 1 < tableTop.Width) { robot.X += 1; } break; case Direction.North: if (robot.Y + 1 < tableTop.Height) { robot.Y += 1; } break; case Direction.South: if (robot.Y - 1 >= 0) { robot.X -= 1; } break; case Direction.West: if (robot.X - 1 >= 0) { robot.X -= 0; } break; } }
public override void Execute(IRobot robot, ITableTop tableTop) { var index = (int)robot.DirectionFacing; index += 1; robot.DirectionFacing = (Direction)(((index % 4) + 4) % 4); }
public void Setup() { _tableTop = new TableTop(); _toyRobot = new ToyRobot(); _inputHelper = new InputHelper(); _robotSimulator = new RobotSimulator(_toyRobot, _tableTop, _inputHelper); }
public ToyRobotSimulator(IReader reader, ITableTop tableTop, IInterpreter interpreter) { _reader = reader; _tableTop = tableTop; _interpreter = interpreter; }
public override void Execute(IRobot robot, ITableTop tableTop) { if (_x < 0 || _x >= tableTop.Width || _y < 0 || _y >= tableTop.Height) { return; } robot.X = _x; robot.Y = _y; robot.DirectionFacing = _directionFacing; }
public RobotSimulator(IToyRobot toyRobot, ITableTop tableTop, IInputHelper inputHelper) { _tableTop = tableTop; _toyRobot = toyRobot; _inputHelper = inputHelper; }
public override void Execute(IRobot robot, ITableTop tableTop) { Console.WriteLine("{0},{1},{2}", robot.X, robot.Y, robot.DirectionFacing); }
public abstract void Execute(IRobot robot, ITableTop tableTop);