Example #1
0
 public JumperToTest(JumperInfo jumperInfo) {
   jumper = new Jumper();
   jumper.setDirection(jumperInfo.beginDirection);
   world.add(jumperInfo.beginLocation, jumper);
   endLocation = jumperInfo.endLocation;
   endDirection = jumperInfo.endDirection;
 }
Example #2
0
 boolean check() {
   return (jumper.getLocation().equals(endLocation) && jumper.getDirection() == endDirection);
 }
Example #3
0
  @Test
  public void testBasicFeature() {
    ActorWorld world = new ActorWorld();
    Jumper a = new Jumper(Color.RED);
    Jumper b = new Jumper(Color.GREEN);
    Jumper c = new Jumper(Color.BLUE);

    world.add(new Location(2, 0), a);
    a.act();
    assertEquals(0, a.getLocation().getRow());
    assertEquals(0, a.getLocation().getCol());
    assertEquals(Location.NORTH, a.getDirection());

    world.add(new Location(1, 3), b);
    b.act();
    assertEquals(0, b.getLocation().getRow());
    assertEquals(3, b.getLocation().getCol());
    assertEquals(Location.NORTH, b.getDirection());
    b.act();
    assertEquals(0, b.getLocation().getRow());
    assertEquals(3, b.getLocation().getCol());
    assertEquals(Location.NORTHEAST, b.getDirection());
    b.act();
    assertEquals(0, b.getLocation().getRow());
    assertEquals(3, b.getLocation().getCol());
    assertEquals(Location.EAST, b.getDirection());
    b.act();
    assertEquals(0, b.getLocation().getRow());
    assertEquals(5, b.getLocation().getCol());
    assertEquals(Location.EAST, b.getDirection());

    world.add(new Location(0, 6), c);
    c.act();
    assertEquals(0, c.getLocation().getRow());
    assertEquals(6, c.getLocation().getCol());
    assertEquals(Location.NORTHEAST, c.getDirection());
    c.act();
    assertEquals(0, c.getLocation().getRow());
    assertEquals(6, c.getLocation().getCol());
    assertEquals(Location.EAST, c.getDirection());
    c.act();
    assertEquals(0, c.getLocation().getRow());
    assertEquals(8, c.getLocation().getCol());
    assertEquals(Location.EAST, c.getDirection());
  }