Beispiel #1
0
 private void PlaceRobotTest(ToyRobot robot, CoordinateXY target, Direction d)
 {
     robot.Place(target, d);
     TestLocation(robot, target, d);
 }
Beispiel #2
0
 private void TestLocation(ToyRobot robot, CoordinateXY expected, Direction expectedDirection)
 {
     Assert.AreEqual(robot.Location.X, expected.X);
     Assert.AreEqual(robot.Location.Y, expected.Y);
     Assert.AreEqual(robot.CurrentDirection, expectedDirection);
 }
Beispiel #3
0
        public List<CoordinateXY> knightMove(int x, int y)
        {
            FigureColor color = cells[x, y].Color;
            CoordinateXY[] travel = new CoordinateXY[]{
                new CoordinateXY{x = -2, y = -1},
                new CoordinateXY{x = -2, y = 1},
                new CoordinateXY{x = 1, y = -2},
                new CoordinateXY{x = -1, y = -2},
                new CoordinateXY{x = 1, y = 2},
                new CoordinateXY{x = -1, y = 2},
                new CoordinateXY{x = 2, y = -1},
                new CoordinateXY{x = 2, y = 1}
            };
            List<CoordinateXY> list = new List<CoordinateXY>();
            CoordinateXY coordinateXY;
            foreach(CoordinateXY elem in travel) {
                int xtemp = x + elem.x;
                int ytemp = y + elem.y;
                if(xtemp >= 0 && xtemp <= 7 && ytemp >= 0 && ytemp <= 7 && cells[xtemp, ytemp].Color != color) {
                    coordinateXY.x = xtemp;
                    coordinateXY.y = ytemp;
                    list.Add(coordinateXY);
                }

            }
            return list;
        }