Beispiel #1
0
        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;
            }
        }
Beispiel #2
0
        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;
 }
Beispiel #5
0
 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;
 }
Beispiel #7
0
 public override void Execute(IRobot robot, ITableTop tableTop)
 {
     Console.WriteLine("{0},{1},{2}", robot.X, robot.Y, robot.DirectionFacing);
 }
Beispiel #8
0
 public abstract void Execute(IRobot robot, ITableTop tableTop);