package com.test;
public class Trangle {
//三条边
private double a;
private double b;
private double c;
//构造方法
public Trangle() {
}
public Trangle(double a, double b, double c) {
this.a = a;
this.b = b;
this.c = c;
}
public double getA() {
return a;
}
public void setA(double a) {
this.a = a;
}
public double getB() {
return b;
}
public void setB(double b) {
this.b = b;
}
public double getC() {
return c;
}
public void setC(double c) {
this.c = c;
}
//判断是否能构成三角形
public static String isTrangle(double a, double b, double c){
if (a>0&&b>0&&c>0) {
if (a+b>c&&a+c>b&&b+c>a) {
double s=(a+b+c)/2;
double area=Math.sqrt(s*(s-a)*(s-b)*(s-c));
return a+","+b+","+c+"能构成三角形,周长为:"+(a+b+c)+",面积为:"+area;
}else{
return "不能构成三角形";
}
}else{
return "边长不能小于等于0";
}
}
}
周长面积可以自己分出来