1 package au.gov.amsa.navigation; 2 3 public class Vector { 4 private final double x; 5 private final double y; 6 7 public Vector(double x, double y) { 8 this.x = x; 9 this.y = y; 10 } 11 12 public double x() { 13 return x; 14 } 15 16 public double y() { 17 return y; 18 } 19 20 public Vector minus(Vector v) { 21 return new Vector(x - v.x, y - v.y); 22 } 23 24 public Vector add(Vector v) { 25 return new Vector(x + v.x, y + v.y); 26 } 27 28 public double dot(Vector v) { 29 return x * v.x + y * v.y; 30 } 31 32 }