public class Circ implements Calculate,GeometryShape {
public float getArea(float r){ //这里写错了!
float area=Calculate.PI*r*r;
return area;
}
public float getCircumference(float r){
float circumference=2*Calculate.PI*r;
return circumference;
}
public void draw(){
System.out.println("画一个圆形!");
}
public static void main(String[] args){
Circ circ=new Circ();
float r=7;
float area=circ.getArea(r);
System.out.println("圆的面积为:"+area);
float circumference=circ.getCircumference(r);
System.out.println("圆的周长为:"+circumference);
circ.draw();
}
}
你还真敢写啊
public class Circ implements Calculate,GeometryShape{
public float getArea(float r){
float area=Calculate.PI*r*r;
return area;
}
public float getCircumference(float r){
float circumference=2*Calculate.PI*r;
return circumference;
}
public void draw(){
System.out.println("画一个圆形!");
}
public static void main(String[] args){
Circ circ=new Circ();
float r=7;
float area=circ.getArea(r);
System.out.println("圆的面积为:"+area);
float circumference=circ.getCircumference(r);
System.out.println("圆的周长为:"+circumference);
circ.draw();
}
}
public class Circ implements Calculate,GeometryShape{
{
public float getArea(float r){
float area=Calculate.PI*r*r;
return area;
}
public float getCircumference(float r){
float circumference=2*Calculate.PI*r;
return circumference;
}
public void draw(){
System.out.println("画一个圆形!");
}
}
public static void main(String[] args){
Circ circ=new Circ();
float r=7;
float area=circ.getArea(r);
System.out.println("圆的面积为:"+area);
float circumference=circ.getCircumference(r);
System.out.println("圆的周长为:"+circumference);
circ.draw();
}
}
方法声明后应该是方法体的{}没有分号的
public float getArea(float r) {
float area=Calculate.PI*r*r;
return area;
}
大括号的位置错了