class bian {
double width;// 定义变量宽
double length;// 定义变量长
double radius; // 定义变量半径
double S;// 定义变量面积
double C;// 定义变量周长
public bian(double width, double length, double radius) {
this.width = width;
this.length = length;
this.radius = radius;
}
}
class Rectangle extends bian implements Shape {//实现接口
通过程序设计几何图形(Shape)、矩形(Rectangle)、圆形(Circle)、正方形(Square)几种类型, 能够利用接口和多态性计算几何图形的面积和周长并显示。
最新推荐文章于 2023-12-04 21:53:43 发布