1.(1)编写一个接口ShapePara,要求: 接口中的方法: int getArea():获得图形的面积。int getCircumference():获得图形的周长 (2)编写一个圆类Circle,要求:圆类Circle实现接口ShapePara。 该类包含有成员变量: radius:public 修饰的double类型radius,表示圆的半径。 x:private修饰的double型变量

//接口 ShapePara

package d922B;

public interface ShapePara {
int getArea();
int getCircumference();

}

//圆类
package d922B;

public class Circle implements ShapePara {
public double radius;
private double x;
protected double y;
Circle(double r)
{
radius=r;
x=0;
y=0;
}
double getRadius()
{
return radius;
}
void setCenter(double a, double b)
{
x=a;
y=b;
}
void setRadius(double r)
{
radius=r;
}
public int getArea() {

	return(int) (Math.PI*radius*radius);
}

public int getCircumference() {
	
	return (int) (2*Math.PI*radius);
}

}

posted @ 2016-09-22 19:46  削肾客  阅读(2847)  评论(0编辑  收藏  举报