Hi,

I'm currently studying Java and have an assignment to create a pool game. I have the bulk of the work done but I am having issues with implementing 2d vectors. I have not been shown this and am trying to work my way through it but cannot find anything which gives suitable explanations for the 2d vector which I am trying to create. I have written a vector class which I have displayed below but need to implement it in my main class. I need to divide the table into a number of squares of my choosing. I then must perform addition of the vectors and determine the new position of the ball objects. I hope someone can help me as I am at a loss at the moment. Also if there is anything else which I should add suggestions will be greatly appreciated. If anyone wants to look at my other classes then they are more than welcome to.

Thanks in advance

poolMan81

import java.awt.*; import java.util.*; //Vector class which contains the code for performing the collisions between the balls public class Vector2 { private double x, y; public Vector2(double x, double y){ this.x = x; this.y = y; } public double getX(){ return this.x; } public double getY(){ return this.y; } public void setVector2(double x, double y) { this.x = x; this.y = y; } public double magnitude(){ return Math.sqrt(x * x + y * y); } public static Vector2 addVector (Vector2 a, Vector2 b) { double sumX = a.getX() + b.getX(); double sumY = a.getY() + b.getY(); return new Vector2 (sumX, sumY); } public static Vector2 scaleVector(double scale, Vector2 d) { return new Vector2 (scale * d.getX(), scale * d.getY()); }