Car.java

public class Car { private double xCoor; private double yCoor; private double velocity; public Car(double x, double y, double v) { xCoor = x; yCoor = y; velocity = v; } public double getXCoor() { return xCoor; } public double getYCoor() { return yCoor; } public double getVelocity() { return velocity; } public void setX(double x) { xCoor = x; } public void setY(double y) { yCoor = y; } public void setVelocity(double v) { velocity = v; } // given the time t returns the distance travelled in time t public double distance(double t) { return t * velocity; } // given the time t and angle a, returns the x,y coordiantes after // travelling for time t in the direction a as an array // element 0 is x element 1 is y public double [] location(double t, double a) { double d = t * velocity; double [] newLoc = new double[2]; newLoc[0] = (Math.cos(Math.toRadians(a)) * d) + xCoor; newLoc[1] = (Math.sin(Math.toRadians(a)) * d) + yCoor; return newLoc; } }