1.包cs2017.vo中包含如下内容:
父类point:包括描述点坐标的私有成员x和y;对成员的set/get方法;构造方法(有参和无参两种);显示点位置(坐标)的toString方法。
Point类的子类Circle:包括描述半径的私有成员radius;对成员radius的set/get方法;构造方法(无参、1个参数、3个参数三种);方法getArea()获得面积,方法toString()输出位置和半径信息(调用父类toString)。
Point类的子类Rectangle:包括描述长和宽的私有成员l和w;对成员l和w的set/get方法;构造方法(无参、2个参数、4个参数四种);方法getArea()获得面积,方法toString()输出位置和长宽信息(调用父类toString)。
Point类:
package cs2017.vo;
public class Point {
private double x;
private double y;
public void setX(double x) {
this.x=x;
}
public double getX() {
return x;
}
public void setY(double y) {
this.y=y;
}
public double getY() {
return y;
}
public Point() {
}
public Point(double x,double y) {
this.x=x;
this.y=y;
}
@Override
public String toString() {
return "坐标(" + x + ", " + y + ")";
}
}
Circle类:
package cs2017.vo;
public class Circle extends Point{
private double radius;
public void setRadius(double radius) {
this.radius=radius;
}
public double getRadius() {
return radius;
}
public Circle() {
}
public Circle(double radius) {
this.radius=radius;
}
public Circle(double x,double y,double radius) {
super(x, y);
this.radius=radius;
}
public double getArea() {
return getRadius()*getRadius()*Math.PI;
}
public String toString() {
return super.toString()+ "半径为:"+radius+",面积为:"+getArea();
}
}
Rectangle类:
package cs2017.vo;
public class Rectangle extends Point{
private double l;
private double w;
public Rectangle() {
}
public Rectangle(double l,double w) {
this.l=l;
this.w=w;
}
public Rectangle(double x,double y,double l,double w) {
super(x,y);
this.l=l;
this.w=w;
}
public void setL(double l) {
this.l=l;
}
public double getL() {
return l;
}
public void setW(double w) {
this.w=w;
}
public double getW() {
return w;
}
public double getArea()