import java.io.*;
public class Test {
public static void main(String[] args) {
Circle circle=new Circle();
Trangle trangle= new Trangle();
Square square=new Square();
Shape shape1=new Shape();
Shape[]myshape={circle,trangle,square};
shape1.draw();
shape1.erase();
myshape[0].draw();
myshape[0].erase();
myshape[1].draw();
myshape[1].erase();
myshape[2].draw();
myshape[2].erase();
}
}
class Shape {
/**
* The constructor for class Shape
*/
public Shape() {
System.out.println("Inside constructor of Shape");
}
/**
* The draw method can not draw anything because it has nothing to draw.
*/
public void draw() {
System.out.println("The draw method in Shape");
}
/**
* The erase method can not erase anything because it has nothing to
* erase.
*/
public void erase() {
System.out.println("The erase method in Shape");
}
}
class Circle extends Shape {
public Circle() {
System.out.println("Inside constructor of Circle");
}
public void draw() {
System.out.println("The draw method in Circle");
}
/**
* The erase method can not erase anything because it has nothing to
* erase.
*/
public void erase() {
System.out.println("The erase method in Shape");
}
}
class Square extends Shape {
public Square() {
System.out.println("Inside constructor of Square");
}
public void draw() {
System.out.println("The draw method in Square");
}
/**
* The erase method can not erase anything because it has nothing to
* erase.
*/
public void erase() {
System.out.println("The erase method in Shape");
}
}
class Trangle extends Shape {
public Trangle() {
System.out.println("Inside constructor of Trangle");
}
public void draw() {
System.out.println("The draw method in Trangle");
}
/**
* The erase method can not erase anything because it has nothing to
* erase.
*/
public void erase() {
System.out.println("The erase method in Shape");
}
}
MicheliaC
- 粉丝: 0
- 资源: 7
最新资源
- 使用漂移和扩散模型模拟pn二极管中的电流和电压的小型MATLAB脚本.rar
- 使用混合模仿强化学习架构的自主赛车Matlab代码.rar
- 使用漂移扩散解算器求解有机器件中的一维静电方程 matlab代码.rar
- 探索在星座上方的高度使用全球导航卫星系统的可行性Matlab代码.rar
- 图像融合评估的仓库,、Qabf、CC、SCD、Nabf、Qcv.rar
- 通过稀疏有界平方和优化可证明的全局最优单位四元数旋转平均 matlab代码.rar
- Matlab基于LSTM长短期记忆神经网络的锂电池寿命预测(含完整的程序,GUI设计和代码详解)
- 特定任务的 DBF(Design Build Fly)竞赛制作的无人机附matlab代码.rar
- 无人机飞行动力学和控制相关Matlab代码 matlab代码.rar
- python线程、队列等应用示例
- 无人机地面站和模拟器附matlab代码.rar
- 无人机道路裂缝检测附matlab代码 matlab代码.rar
- 无人机飞行控制系统模型SIMULINK代码 matlab代码.rar
- 无人机辅助边缘计算python代码.rar
- 无人机浮标系统的MATLAB Simulink实现.rar
- 无人机辅助移动边缘计算的计算卸载优化:一种深度确定性策略梯度方法python代码.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈