package add;
import java.util.*;
class Rectangle{ //不需要添加public
double length;
double width;
public Rectangle(){} //有无不重要
public Rectangle(double length,double width){ //构造函数
this.length=length;
this.width=width;}
public double area(double length,double width){ //重写方法
double Area=length*width;
return Area;
}
public void showInfo(){
System.out.println("底面积Area="+length*width);
}
}
class Cuboid extends Rectangle{
double height;
public Cuboid(){}
public Cuboid(double length,double width,double height){
super(length,width);
this.height=height;
}
public double Volume(){
double volume=length*width*height;
return volume;
}
public void showInfo(){
System.out.println("体积volume="+length*width*height);
}
}
public class test{
public static void main(String[] args){
Rectangle c2 = new Rectangle(3.1,4.2);
c2.showInfo();
Cuboid c1 = new Cuboid(3.1,4.2,5.3);
c1.showInfo();
}
}