public class Vector2D private double private double public double getX

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
public class Vector2D {
private double x;
private double y;
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
public Vector2D() {
this(0,0);
}
public Vector2D (double x, double y) {
this.x = x;
this.y = y;
}
public void mult(double a) {
this.x *= a;
this.y *= a;
}
public Vector2D mult2(double a) {
return new Vector2D(x * a, y * a);
}
public String toString() {
return("(" + x + ", " + y + ")");
}
}