2D Point Collisions

For this programming assignment, you will implement a Java class that represents simple particles in twoo dimensional space. These particles have no mass and there are no external forces acting on these particles. Each particle has a location and a velocity. For this part of the assignment, we only want to be able to do a couple of things with particles:

  1. Create a particle: when it is created, each particle must be given a position and velocity
  2. Move a particle: update time (by adding to the current time)
  3. Find out where a particle is: get the position of a particle
  4. Determine if two particles will collide
  5. Determine when two particles will collide

Your class should be called Particle and it will implement the following methods:

  1. a constructor that takes four double values, defining a particle: xPos, yPos, xVel, and yVel
  2. getX, which returns the x position of the particle
  3. getY, which returns the y position of the particle
  4. advanceTime, which takes and argument of type double and moves the particle forward in time by the amount passed as an argument
  5. whenCollide, which takes an argument of type Particle, and returns the time of the collision (a double) or -1 if there is no collision

A sample driver is available here.