来个大佬帮一下吧。。
package com.chouxiang;
public abstract class Shape {
int r;
int a;
int b;
public abstract void zhouchang();
public abstract void mianji();
}
package com.chouxiang;
public class juxing extends Shape {
@Override
public void zhouchang() {
System.out.println((a+b)*2);
}
@Override
public void mianji() {
System.out.println(a*b);
}
}
package com.chouxiang;
public class yuanxing extends Shape {
@Override
public void zhouchang() {
// TODO Auto-generated method stub
System.out.println(6*r);
}
@Override
public void mianji() {
// TODO Auto-generated method stub
System.out.println(3*r*r);
}
}
package com.chouxiang;
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Shape c=new juxing();
Shape d=new yuanxing();
c.a=6;
c.b=4;
d.r=2;
System.out.println("矩形周长为"+c.zhouchang+"\n"+"矩形面积为"+c.mianji);
System.out.println("圆形周长为"+d.zhouchang+"\n"+"圆形面积为"+d.mianji);
}
}