主题:新手 帮忙看看错在哪里 谢谢
public class Retangle{
public Retangle(double l,double w){
length=l;
width=w;
}
public double calcP(){
return 2*(length+width);
}
public double calcA(){
return length*width;
}
public Sting ToString(){
return"长为"+length+"宽为"+width+"的长方形";
}
protected double length;
private double width;
}
public class Square extends Retangle{
public Square double side(){
super(side,side);
}
public double calc Perime ter(){
return length*4;
}
public String ToString(){
return"边长为"+length+"的正方形";
}
}
public class ShareTest{
public static void main(String[] srgs){
Retangle retangle=new Retangle(10.0,20.0);
Square square=new Square(10.0);
System.out.println(retangle+"周长"+retangle.calcP());
System.out.println(retangle+"面积"+retangle.calcA());
System.out.printlna(square+"周长"+square.calcP());
System.out.println(square+"面积"+square.clacA());
}
}
public Retangle(double l,double w){
length=l;
width=w;
}
public double calcP(){
return 2*(length+width);
}
public double calcA(){
return length*width;
}
public Sting ToString(){
return"长为"+length+"宽为"+width+"的长方形";
}
protected double length;
private double width;
}
public class Square extends Retangle{
public Square double side(){
super(side,side);
}
public double calc Perime ter(){
return length*4;
}
public String ToString(){
return"边长为"+length+"的正方形";
}
}
public class ShareTest{
public static void main(String[] srgs){
Retangle retangle=new Retangle(10.0,20.0);
Square square=new Square(10.0);
System.out.println(retangle+"周长"+retangle.calcP());
System.out.println(retangle+"面积"+retangle.calcA());
System.out.printlna(square+"周长"+square.calcP());
System.out.println(square+"面积"+square.clacA());
}
}