//(1)定义一个类,描述一个矩形,包含有长、宽两种属性,和计算面积方法。
//(2)编写一个类,继承自矩形类,长方体,具有长、宽、高属性,和计算体积的方法。
//(2)编写一个类,继承自矩形类,长方体,具有长、宽、高属性,和计算体积的方法。
//(3)编写一个测试类,对以上两个类进行测试,创建一个长方体,定义其长、宽、高,输出其底面积和体积。
class Rectangle
{
public float wide;
public float length;
public Rectangle(float wide,float length) {
this.wide = wide;
this.length = length;
}
public float GetArea() {
float S = wide * length;
return S;
}
}
class Cub : Rectangle {
public float height;
public Cub(float wide, float length,float height) :base(wide,length) {
this.height = height;
}
public float GetArea()
{
float S = wide * length;
return S;
}