triangle.Java
时间: 2023-09-25 20:13:01 浏览: 76
Personalize-My-Triangle:让您知道三角形是锐角、钝角还是直角并计算面积
I am assuming you are asking about a Java file named "Triangle.java". This is likely a class file that defines the properties and behavior of a Triangle object. It may contain methods to calculate the area, perimeter, and other properties of a triangle, as well as constructors to create Triangle objects with different parameters, such as side lengths or angles.
Here is an example implementation of a Triangle class in Java:
```
public class Triangle {
private double side1;
private double side2;
private double side3;
public Triangle(double s1, double s2, double s3) {
side1 = s1;
side2 = s2;
side3 = s3;
}
public double getSide1() {
return side1;
}
public double getSide2() {
return side2;
}
public double getSide3() {
return side3;
}
public double getPerimeter() {
return side1 + side2 + side3;
}
public double getArea() {
double s = getPerimeter() / 2;
return Math.sqrt(s * (s - side1) * (s - side2) * (s - side3));
}
}
```
This implementation includes a constructor that takes the lengths of the three sides as parameters, as well as methods to get the side lengths, perimeter, and area of the triangle. Note that this is just one possible implementation, and there are many ways to define a Triangle class in Java.
阅读全文