Fence extends BaseObject { @Override public String getTileType() { if (!isGate) { if (location == "BL") { return "fenceBL"; } else if (location == "BR") { return "fenceBR"; } else if (location == "H") { return "fenceH"; } else if (location == "P") { return "fenceP"; } else if (location == "TL") { return "fenceTL"; } else if (location == "TR") { return "fenceTR"; } else if (location == "V") { return "fenceV"; } else if (location == "T") { return "fenceT"; } else { return "fenceP"; } } else { if (gateOpen) { return "fenceGateOpen"; } else { return "fenceGateClosed"; } } } Fence(Tile parent, String location, boolean isGate); void toggleGate(); boolean isGateOpen(); @Override String getTileType();  }
@Test public void testGetTileType() { Tile testTile = new Tile(0, 0, 1); String[] tileTypes = {"fenceBL", "fenceBR", "fenceH", "fenceP", "fenceTL", "fenceTR", "fenceV", "fenceT", "fenceP"}; String[] locations = {"BL", "BR", "H", "P", "TL", "TR", "V", "T", "P"}; int i = 0; for (String type: tileTypes) { Fence fence = new Fence(testTile, locations[i], false); assertEquals(type, fence.getTileType()); i++; } Fence fence = new Fence(testTile, null, true); assertEquals("fenceGateClosed", fence.getTileType()); fence.toggleGate(); assertEquals("fenceGateOpen", fence.getTileType()); }