Fence extends BaseObject { public void toggleGate() { if (gateOpen) { gateOpen = false; getParent().setProperty(TileProperty.PASSABLE, false); } else { gateOpen = true; getParent().setProperty(TileProperty.PASSABLE, true); } } Fence(Tile parent, String location, boolean isGate); void toggleGate(); boolean isGateOpen(); @Override String getTileType();  }
@Test public void testToggleGate() { Tile testTile = new Tile(0, 0, 1); Fence fence = new Fence(testTile, null, true); assertEquals(false, fence.isGateOpen()); fence.toggleGate(); assertEquals(true, fence.isGateOpen()); fence.toggleGate(); assertEquals(false, fence.isGateOpen()); }