新手 帮忙看看错在哪里。
import java.util.*;interface Shape{
public double getArea();
public double getVolume();
public String getName();
}
class Point implements Shape{
private int x;
private int y;
public Point(){
x=0;
y=0;
}
public Point(int x,int y){
this.x=x;
this.y=y;
}
public int getX(){
return x;
}
public double getArea(){
return 0.0;
}
public double getVolume(){
return 0;
}
public String getName(){
return "Point";
}
}
class Circle{
private double r;
private Point center;
public Circle(){
center=new Point();
r=0.0;
}
public Circle(int x,int y,double r){
center=new Point(x,y);
this.r=r;
}
public void setRadius(double r){
this.r = r;
}
public double getRadius(){
return r;
}
public double getArea(){
return Math.PI*getRadius()*getRadius();
}
public double getCircumference(){
return 2*Math.PI*getRadius();
}
public String getName(){
return "Circle";
}
public String toString(){
String s = center.toString();
s+=",半径:"+r+",";
return s;
}
}
class Cylinder extends Circle{
double h;
public Cylinder(){
super();
h=0.0;
}
public Cylinder(int x,int y,double r,double h){
super(x,y,r);
this.h = h;
}
public double getHeight(){
return h;
}
public void setHeight(double h){
this.h = h;
}
public double getArea(){
return 2*Math.PI*getRadius()*getRadius() + 2*Math.PI*getRadius()*getHeight();
}
public double getVolume(){
return Math.PI*getRadius()*getRadius()*getHeight();
}
public String getName(){
return "Cylinder";
}
public String toString(){
String s = super.toString();
s+="高:"+getHeight()+",";
return s;
}
}
public class Sun22{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
int a,b;
double c,d;
while(true){
System.out.println("输入圆柱体的底心坐标[x,y], 以及它的半径和高(坐标必须是正整数,其它必须为正数)");
a=input.nextInt();
b=input.nextInt();
c=input.nextDouble();
d=input.nextDouble();
Cylinder c2=new Cylinder(a,b,c,d);
System.out.print(c2.toString());
System.out.printf("体积:%.0f,表面积:%.0f",c2.getVolume(),c2.getArea());
System.out.printf("\n输入911退出:");
String s=input.next();
if(("911")==0)
break;
}
System.out.println("Have a nice day!");
}
}