我写了个 写的是不太好 但就是说明下这个意思
class TuXing{
//定义边长
double c,k;
//构造方法
public TuXing(){
}
//求面积方法
public double mj(double c,double k){
return (c*k);
}
//重载
public double mj(double c){
return 0;
}
//求周长方法
public double zc(double c,double k){
return (2*(c+k));
}
public double zc(double c){
return 0;
}
}
class zhengfang extends TuXing{
double b;
public zhengfang(){
}
//重写父类方法
public double mj(double a){
return (a*a);
}
public double zc(double b){
return 4*b;
}
}
public class Testt{
public static void main(String[] args) {
TuXing a=new zhengfang();
System.out.println( "mj=" +a.mj(3.0));
System.out.println( "zc=" +a.zc(4.0));
TuXing m= new TuXing();
System.out.println(m.mj(3.0,4.0)+"\t"+m.zc(4.0,5.0));
}
}