title: Java Collision detection between different classes
body: <p>I am making a simple game about shooting enemies and avoiding obstacles, but I have a problem with detecting collisions because I've got a lot of classes for every type of game object (player,enemy,obstacle,drop,bullet, etc.).</p>
  
  <pre><code>class Player { Vector3 pos; ... }
  class Enemy { Vector3 pos; ... }
  class Obstacle { Vector3 pos; ... }
  ...
  
  boolean doCollide (Object a, Object b)
  {
  
      if ( a.pos.x + a.size.w &gt;= b.pos.x ) { ... }
  
      ...
  }
  </code></pre>
  
  <p>And it won't work because a doesn't have 'pos', etc, so how can I do it so it works for every class? I've read about interfaces but I don't really know how can it help me. </p>