java继承小问题,请求帮忙
import java.applet.*;import java.awt.*;
class area{
double f(double r){
return 3.14*r*r;
}
double g(double x,double y){
return 0.5*x*y;
}
}
class circle extends area{
double f(double r){
return 3.14*2.0*r;
}
}
public class PolyMorphism_Example1 extends Applet{
area obj;
circle cir;
public void init(){
obj=new area();
cir=new circle();
}
public void paint(Graphics g){
g.drawString("圆的面积:"+obj.f(5.0),5,20);
g.drawString("圆的周长:"+cir.f(5.0),5,40);
g.drawString("三角形的面积:"+cir.g(2.0,8.0),5,60);
}
}
为什么只出面积,其他的没出,谢谢!