package ru.job4j.condition;

/**.
 * Class Point solving task for part 3 lesson 3.3
 * @author Mikhail Vlasov
 * @since 4.6.2017
 * @version 1
 */
public class Triangle {

	/**.
	 * Point a
	 */
	private Point a;

	/**.
	 * Point b
	 */
	private Point b;

	/**.
	 * Point c
	 */
	private Point c;

	/**.
	 * Constructor
	 * @param a defines a
	 * @param b defines b
	 * @param c defines c
	 */
	public Triangle(Point a, Point b, Point c) {
		this.a = a;
		this.b = b;
		this.c = c;
	}

	/**.
	 * Calculating triangle area
	 * @return double area
	 */
	public double area() {
		//calculate the triangle area
		double aB = Math.sqrt(Math.pow((double) (this.a.getX() - this.b.getX()), 2D) + Math.pow((double) (this.a.getY() - this.b.getY()), 2D));
		double bC = Math.sqrt(Math.pow((double) (this.b.getX() - this.c.getX()), 2D) + Math.pow((double) (this.b.getY() - this.c.getY()), 2D));
		double aC = Math.sqrt(Math.pow((double) (this.a.getX() - this.c.getX()), 2D) + Math.pow((double) (this.a.getY() - this.c.getY()), 2D));
		double semiperimeter = (aB + aC + bC) / 2;
		double area = Math.sqrt((semiperimeter - aB) * (semiperimeter - aC) * (semiperimeter - bC) * semiperimeter);

		if (area == 0) {
			System.out.println("No triangle can be built");
			return 0;
		}

		return area;
	}
}
@@ -22,16 +22,86 @@
 ition;%0A%0A
+import static java.lang.Math.pow;%0Aimport static java.lang.Math.sqrt;%0A%0A
 /**.%0A * 
@@ -688,405 +688,117 @@
 B = 
-Math.sqrt(Math.pow((double) (this.a.getX() - this.b.getX()), 2D) + Math.pow((double) (this.a.getY() - this.b.getY()), 2D));%0A%09%09double bC = Math.sqrt(Math.pow((double) (this.b.getX() - this.c.getX()), 2D) + Math.pow((double) (this.b.getY() - this.c.getY()), 2D));%0A%09%09double aC = Math.sqrt(Math.pow((double) (this.a.getX() - this.c.getX()), 2D) + Math.pow((double) (this.a.getY() - this.c.getY()), 2D)
+lineLength(this.a, this.b);%0A%09%09double bC = lineLength(this.b, this.c);%0A%09%09double aC = lineLength(this.a, this.c
 );%0A%09
@@ -857,21 +857,16 @@
  area = 
-Math.
 sqrt((se
@@ -1053,10 +1053,322 @@
 area;%0A%09%7D
+%0A%0A%09/**.%0A%09 * Calculating line length%0A%09 * @param first point of the line%0A%09 * @param second point of the line%0A%09 * @return double length%0A%09 */%0A%09private double lineLength(Point first, Point second) %7B%0A%09%09return sqrt(pow((double) (first.getX() - second.getX()), 2D) + pow((double) (first.getY() - second.getY()), 2D));%0A%09%7D
 %0A%7D

task 9461