/*
使用继承与多态的思想。
优点:
避免了代码的重复,降低了程序的耦合度,
便于以后的维护。
*/
public class Ex2 {
public static void main(String[] args) {
Ex2 e = new Ex2();
e.print(new Circle(10));
e.print(new Rectangle(5, 4));
e.print(new Triangle(7));
}
public void print(Graph g) {
使用继承与多态思想编写矩形,等边三角形,圆,求周长与面积
最新推荐文章于 2021-12-07 09:09:43 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)