【交作文 】大家看看还需要哪些改进 小白求教@!!!
package com.imooc;
public abstract class Shape {
public abstract void hello (String girth,String area);
}
-------------------------------------------------
package com.imooc;
public class Rectangle extends Shape {
@Override
public void hello(String girth,String area) {
// TODO Auto-generated method stub
System.out.println("矩形的周长是:"+girth+",面积是:"+area);
}
}
--------------------------------------------------------
package com.imooc;
public class Circle extends Shape {
@Override
public void hello(String girth, String area) {
// TODO Auto-generated method stub
System.out.println("圆形的周长是:"+girth+",面积是:"+area);
}
}
------------------------------------------------------------
package com.imooc;
public class Text {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Shape rec=new Rectangle();
rec.hello("2(a+b)", "a*b");//a为矩形的长,b为矩形的宽。
Shape cir=new Circle();
cir.hello("2Math.PIr","Math.PIr²" );
}
}
-----------------------------------------------------
矩形的周长是:2(a+b),面积是:a*b
圆形的周长是:2Math.PIr,面积是:Math.PIr²