Почему переменная result равна 0?
public class Point2{
private int x;
private int y;
public Point2(){
x=y=0;
System.out.println("Конструктор без параметров, х = " + x + " y = " + y);
}
public Point2(int x0, int y0){
this.x = x0;
this.y = y0;
System.out.println("Конструктор с параметрами , х = " + x + " y = " + y);
}
public double dist(){
double a, b, r;
a = x * x;
b = y * y;
r = Math.sqrt(a + b);
System.out.println("Расстояние от (0,0) до (" + x + ", " + y + " ) =" + r);
return r;
}
public double distBetween(Point2 p){
double a, b, r;
a = x - p.x;
b = y - p.y;
r = Math.sqrt(a * a + b * b);
System.out.println("Расстояние от (" + x + ", " + y + " ) до (" + p.x + ", " + p.y + " ) =" + r);
return r;
}
public static double gerouneArea(double a, double b, double c){
double ar, p;
p = (a + b + c) / 2;
ar = Math.sqrt((p - a) * (p - b) * (p - c));
return ar;
}
}
public class Test5a{
public static void main(String[] args){
Point2[] point = new Point2[3];
point[0] = new Point2(1, 2);
point[1] = new Point2(7, 4);
point[2] = new Point2(4, 3);
double d = point[0].dist();
double d1 = point[0].distBetween(point[1]);
double d2 = point[1].distBetween(point[2]);
double d3 = point[2].distBetween(point[0]);
double result = Point2.gerouneArea(d1, d2, d3);
System.out.println("Square of triange is equal: " + result);
}
}