I am making a basic game with geometric figures.I am trying to design now how to calculate if the figure collides with another figure in an Array List of figures (called entitiesList).I have:Class Entity {   ...   public boolean collidesWith(Entity anotherEntityInMap) {}}But I can't figure out how I  should make this. I guess I must know what kind of figure is anotherEntity. For example, I can have squares, triangles and circles. Each figure has diverse calculations, and it must be abstracted.
How to design a class to check if geometric figures collide?
object oriented design;class design
The most academically proper way of doing it would be to have a two-dimensional matrix of collision detection methods, one method for each possible pair of figures, so each method would have knowledge of precisely what figures are being checked, so as to do the checking in the best way possible.  Unfortunately, this is too much work for very little benefit.The quickest, dirtiest, simplest, hackiest and most inaccurate way of doing it would be to treat all shapes equally, consider them all to be circles, and just check the distance between their centerpoints to determine if they collide.A practical solution which is not too difficult to implement and yields accurate results is to have each shape contain a polygon representation of itself, and simply make use of a single polygon collision detection algorithm to detect collision between the polygon representations of any two shapes.