Hello everyone!
I'm working on a project and I must know if an object is in the proximity of another one. I think about creating a method that takes as parameter an object and returns `true` or `false` but I don't know exactly how to do that.
I am not sure if you really want/need to use two objects here. Would be helpful if you could describe your project.
For example if you have an animal which begins to hunt another one (two different classes) if it is in a certain range, it should be enough to use the 'getObjectsInRange' method.
In this case, you can use the 'getObjectsInRange' methods. I guess you could create a superclass for Moon, Mars, ... (maybe call it 'SpaceObjects' or whatever you like). Then you can use this class as the parameter in the 'getObjectsInRange' method. The method returns a list. If you only want to know if one of those objects is in a certain range, you can check if the list is empty or not. If you want to react to them (like not flying into it or landing on it), you can use a for-each on the list.