package com.hanqi.test;
public class Triangle {
private double a,b,c;
public Triangle(double d,double f,double g)
{
if(d+f>g&d+g>f&f+g>d)
{
a=d;
b=f;
c=g;
}
else
{
System.out.println("不能构成三角形");
}
}
public void zhouChang()
{
if (a!=0)
{
System.out.println(a+b+c);
}
}
}
//主类
package com.hanqi.test;
public class A {
public static void main(String[] args) {
Triangle a=new Triangle(1,2,3);
a.zhouChang();
a=new Triangle(5,7,9);
a.zhouChang();
}
}
//运行结果
不能构成三角形
21.0