示例#1
2
  @Test
  public void testMoveForward() throws Exception {
    final Coords base = new Coords(0, 0);

    final Coords northMove = NORTH.moveForward(NORTH.moveForward(NORTH.moveForward(base)));
    assertEquals(new Coords(0, 3), northMove);

    final Coords southMove = SOUTH.moveForward(SOUTH.moveForward(SOUTH.moveForward(base)));
    assertEquals(new Coords(0, -3), southMove);

    final Coords eastMove = EAST.moveForward(EAST.moveForward(EAST.moveForward(base)));
    assertEquals(new Coords(3, 0), eastMove);

    final Coords westMove = WEST.moveForward(WEST.moveForward(WEST.moveForward(base)));
    assertEquals(new Coords(-3, 0), westMove);
  }
示例#2
0
 @Test
 public void testTurnLeft() throws Exception {
   assertEquals(NORTH.turnLeft(), WEST);
   assertEquals(WEST.turnLeft(), SOUTH);
   assertEquals(SOUTH.turnLeft(), EAST);
   assertEquals(EAST.turnLeft(), NORTH);
 }