用java设计一个类Triangle,它有三个double型属性;

2024-11-07 13:41:28
推荐回答(3个)
回答1:

public class Triangle {
private double a;
private double b;
private double c;
public Triangle() {
this.a=0;
this.b=0;
this.c=0;
}
public Triangle(double a,double b,double c) {
this.a=a;
this.b=b;
this.c=c;
}
private boolean isTrue(double a,double b,double c){
if(a+b> c || a+c> b || b+c > a){
return true;
}else{
return false;
}
}
private double getPerimeter() {
boolean dd=this.isTrue(a, b, c);
double ee=a+b+c;
if(dd){
return ee;
}else{
return -1;
}
}
private double getArea(){
boolean dd=this.isTrue(a, b, c);
double ee=(a+b+c)/2;
if(dd){
return ee;
}else{
return -1;
}

}
private double getmianjiandzhouchang(double a,double b,double c){
this.a=a;
this.b=b;
this.c=c;
double zhouchang=a+b+c;
double mianji=(a+b+c)/2;
if(a+b> c || a+c> b || b+c > a){
return zhouchang;
}
return mianji;

}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}

回答2:

没分没动力呀

public class Triangle{
double a;

double b;

double c;

Triangle(){};//不设置默认不就是0吗

Triangle(double a,double b,doulbe c){

未完待续…………呵呵!

}

}

回答3:

我是游戏二班的java课老师,