public interface Scalarable double scalarProduct Point2D public abstra

 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
public interface Scalarable {
double scalarProduct(Point2D p);
}
public abstract class Point implements Scalarable {
public Point() { }
public String toString() {
return "Some point. ";
}
}
public class Point2D extends Point {
double x;
double y;
public Point2D(double x, double y) {
super();
this.x = x;
this.y = y;
}
public String toString() {
return super.toString() +
"2D point. X - " + x + " Y - " + y;
}
@Override
public double scalarProduct(Point2D p) {
return Math.sqrt(x * p.x + y * p.y);
}
}