class Square
{
int length;
Square(int len)
{
length=len;
}
void getPerimeter()
{
System.out.println("正方形的周长为" + (4*length) );
}
}
class Rectangle extends Square
{
int width;
Rectangle(int len,int wid)
{
super(len);
width=wid;
}
void getPerimeter()
{
System.out.println("矩形的周长为"+(2*(width+length)));
}
}
public class Calculate
{
Calculate()
{
}
public static void main(String[] args)
{
Square sqObj = new Square(15);
sqObj.getPerimeter();
Square rectObj = new Square(10);
rectObj.getPerimeter();
}
}
你这个程序有问题,这样就对了