java求圆面积的程序
发布网友
发布时间:2022-05-15 20:39
我来回答
共1个回答
热心网友
时间:2024-02-27 18:36
interface Shape
{
final double PI = 3.15169;
double getArea();
}
class Circle implements Shape
{
private double radius;
public Circle(double r) {this.radius = r;}
public double getRadius() {return this.radius;}
public void setRadius(double r) {this.radius = r;}
public double getArea()
{
return radius * radius * PI;
}
}
public class Test
{
public static void main(String[] args)
{
Circle c = new Circle(3);
System.out.println("Area is " + c.getArea());
}
}追问首先谢谢你,我想问这一个程序包含了上面的所有方法吗?