编写一个简单java应用程序

2020-10-27 教育 172阅读
class Trangle{
private double a, b, c;//三个边
private double area;//面积
private double perimeter;//周长

public double getArea() {//返回面积
return area;
}
public double getPerimeter() {//返回周长
return a+b+c;
}
public void setA(double a) {//修改边a
this.a = a;
}
public void setB(double b) {//修改边b
this.b = b;
}
public void setC(double c) {////修改边c
this.c = c;
}

public static boolean isTrangle(double a, double b, double c){//判断三个数能否构成一个三角形
if(a <= 0 || b <=0 || c<=0){
return false;
}

return a + b > c && a + c > b && b + c > a;
}

}
class Lader{
private double a;//上底
private double b;//下底
private double h;//高
private double area;//面积
public double getArea() {//返回面积
return (a+b)*h/2;
}
}
class Circle{
private double r;//半径
private double perimeter;//周长
private double area;//面积
public double getArea() {//返回面积
return 3.14* r * r;
}
public double getPerimeter() {//返回周长
return 3.14*2*r;
}
}
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com