实在是不会做了,求助各位,谢谢了
设计一个点类,他仅包含两个属性:横坐标和纵坐标.通过继承点类再设计一个圆类,他除了有一个圆心还有半径,还应该能计算周长和面积等,编写一个程序来测试所设计的类能否实现预定功能. class Point{
private double h;//横坐标
private double z;//纵坐标
public Point(double h,double z){
this.h=h;
this.z=z;
}
public Point{
}
public double geth(){
return this.h;
}
public doubel seth(double h){
this.h=h;
}
public double getz(){
return this.z;
}
public double setz(double z){
this.z=z;
}
}
class Circle extends Point{
private double hc;//圆心的横坐标
private double zc;//圆心的纵坐标
private double radius;
private double perimeter;
private double area;
private double pi=3.14;
private double D;
public Circle(double hc,double zc){
this.hc=hc;
this.zc=zc;
}
public double sethc(double hc){
this.hc=hc;
}
public double gethc(){
return this.hc;
}
public double setzc(double zc){
this.zc=zc;
}
public double gethc(){
return this.zc;
}
D=((geth()-gethc())*(geth()-gethc()))+((getz()-getzc())*(getz()-getzc()));
public static void main(String[] args){
Point p=new Point(3,4);
Circle c=new Circle(0,0);
System.out.println("圆的面积为:"+(pi*D));
}
}
请帮忙修改