JAVA编程!急急急!!!

来源:百度知道 编辑:UC知道 时间:2024/05/05 09:25:21
急!!!急!!!急!!!
求下面三个JAVA的编程,要全部的程序!!!
1、编写一个抽象类Shape,其中有抽象方法GetArea()和GetPerimeter()。
2、在Shape类的基础上派生出Rectangle(属性:长、宽)和Circle类(属性:半径),均实现计算面积的方法,GetAra()和计算周长的方法和GetPerimeter()。
3、修改Circle类的实现,使由Circle类对象的数组可以使用Arrays.sort方法依据半径排序。

1.public abstract class Shape {
public abstract double GetArea();
public abstract double GetPerimeter();

}

2.public class Rectangle extends Shape{

private double length;
private double width;
Rectangle(){}
Rectangle(double length,double width){
this.length=length;
this.width=width;
}
public double GetArea() {

return length*width;
}

/* (非 Javadoc)
* @see com.san.db.Shape#GetPerimeter()
*/
public double GetPerimeter() {
// TODO 自动生成方法存根
return (length+width)*2;
}
/**
* @return 返回 length。
*/
public double getLength() {
return length;
}
/**
* @param length 要设置的 length。
*/
public void setLength(double length) {
this.length = length;
}
/**
* @return 返回 width。
*/
public double getWidth() {
return width;
}