能出结果 但是编译显示错误,各位大神看看
package com.imooc;
public abstract class Shape {
public abstract void zhouchang(double a,double b);
public abstract void zhouchang(double r);
public abstract void area(double a,double b);
public abstract void area(double r);
}
package com.imooc;
public class Rectangle extends Shape {
@Override
public void zhouchang(double a, double b) {
// TODO Auto-generated method stub
double s=2*(a+b);
System.out.println("矩形的周长是: "+s);
}
@Override
public void area(double a, double b) {
// TODO Auto-generated method stub
double s=a*b;
System.out.println("矩形的面积是: "+s);
}
}
package com.imooc;
public class Circle extends Shape {
@Override
public void zhouchang(double r) {
// TODO Auto-generated method stub
double s=2*3.14*r;
System.out.println("圆的周长是: "+s);
}
@Override
public void area(double r) {
// TODO Auto-generated method stub
double s=3.13*r*r;
System.out.println("圆的面积是: "+s);
}
}
package com.imooc;
public class Initial {
public static void main(String[] args) {
// TODO Auto-generated method stub
Rectangle rec=new Rectangle();
rec.zhouchang(3, 4);
rec.area(3, 4);
Circle cir=new Circle();
cir.zhouchang(3);
cir.area(3);
}
}