public static boolean isValidCoordinate(Coordinate point) {
Point map = point.mapCoordinates, tileSet = point.tileSetCoordinates, tile = point.tileCoordinates, pixel = point.pixelCoordinates;
if (map != null && map.x >= 0 && map.y >= 0) {
if (tileSet != null) {
if (tileSet.x >= 0 && tileSet.y >= 0) {
if (tile != null) {
if (tile.x >= 0 && tile.y >= 0) {
if (pixel != null) {
if (pixel.x >= 0 && pixel.y >= 0) {
return true;
}
else {
return false;
}
}
else {
return true;
}
}
else {
return false;
}
}
else {
return true;
}
}
else {
return false;
}
}
else {
return true;
}
}
else {
return false;
}
}
The coordinate class holds 4 Point objects, representing a unique set of coordinates. Each set of coordinates needs to be positive. mapCoordinates cannot be null, but the other Points can, as long as everything after them is null, and everything before them is positive in this list: mapCoordinates, tileSetCoordinates, tileCoordiantes, pixelCoordinates. Thanks
Of course there is. Use methods to keep DRY:
And yes, calling the variables of type
Pointcoordinateand those of typeCoordinatepointis likely to confuse the reader.