boolean driveDone() { int low, high; switch (sourceZone) { case RESIDENTIAL: low = COMBASE; high = NUCLEAR; break; case COMMERCIAL: low = LHTHR; high = PORT; break; case INDUSTRIAL: low = LHTHR; high = COMBASE; break; default: throw new Error("unreachable"); } if (mapY > 0) { int tile = city.getTile(mapX, mapY - 1); if (tile >= low && tile <= high) return true; } if (mapX + 1 < city.getWidth()) { int tile = city.getTile(mapX + 1, mapY); if (tile >= low && tile <= high) return true; } if (mapY + 1 < city.getHeight()) { int tile = city.getTile(mapX, mapY + 1); if (tile >= low && tile <= high) return true; } if (mapX > 0) { int tile = city.getTile(mapX - 1, mapY); if (tile >= low && tile <= high) return true; } return false; }