package ru.job4j.condition;

import org.junit.Test;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.number.IsCloseTo.closeTo;

public class Triangle {
    private Point a;
    private Point b;
    private Point c;

    public Triangle(Point a, Point b, Point c){
        this.a=a;
        this.b=b;
        this.c=c;
    }

    public double distance(Point left, Point right) {
        double result;
        result = Math.sqrt( ( (right.getX()-left.getX())^2 ) + ( (right.getY()-left.getY())^2 )  );
        return result;
    }

    public double period(double ab, double ac, double bc) {
        double result;
        result = (this.distance(this.a,this.b) + this.distance(this.a,this.c) + this.distance(this.b,this.c)) / 2;
        return result;
    }

    public double area() {
        double rsl = -1;
        double ab = this.distance(this.a, this.b);
        double ac = this.distance(this.a, this.c);
        double bc = this.distance(this.b, this.c);
        double p = this.period(ab, ac, bc);
        if (this.exist(ab, ac, bc)) {
            //√ p *(p - ab) * (p - ac) * (p - bc)
            rsl = Math.sqrt( p*(p-ab) *(p-ac)* (p-bc) );
        }
        return rsl;
    }

    private boolean exist(double ab, double ac, double bc) {
        double sum = ab + ac;
        if (sum > bc & ab > 0 & ac > 0 & bc > 0) {
            return true;
        } else {
            return false;
        }
    }

}

@@ -1280,16 +1280,17 @@
 uble sum
+1
  = ab + 
@@ -1292,16 +1292,104 @@
 ab + ac;
+ // %3E bc%0A        double sum2 = ab + bc;  // %3E ac%0A        double sum3 = ac + bc; // %3E ab%0A
 %0A       
@@ -1400,15 +1400,40 @@
 (sum
+1
  %3E bc &
+ sum2 %3E ac & sum3 %3E ab &
  ab 

edit task #9461