求大神帮忙解决
java编写一个三角形类,成员变量包括底和高,设置方法,返回三角形面积的方法
三角形是正三角形?
public class Triangle {
private double height;
private double bottom;
public Triangle(double height, double bottom) {
this.height = height;
this.bottom = bottom;
}
public double getArea(){
return 0.5*height*bottom;
}
public static void main(String[] args) {
Triangle t=new Triangle(3,4);
System.out.println("三角形面积为:"+t.getArea());
}
}
/**
三角形类
/
public class Triangle {
private Double h;//三角形高
private Double m;//底边
public Triangle() {
}
public Triangle(Double h, Double m) {
this.h = h;
this.m = m;
}
public Double area(){
return h*m*0.5;
}
}