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
最新资源
- 23552679郭磊.zip
- RabbitMQ的介绍与安装使用
- report ETL .ffff
- 大数据+机器学习+机器学习问题引出
- 西门子s7 200smart与3台欧姆龙E5cc温控器通讯控 功能:可以直接应用现场 实现西门子s7 200smart对3台欧姆
- 《图书管理系统》JavaSE:循环、判断
- Matlab 车辆配送路径规划问题 四大算法解决旅行商问题(TSP) CVRP CDVRP VRPTW tsp:旅行商问题,寻
- 交直流混合微网程序matlab 采用拉丁超立方抽样和多场景缩减,考虑风光等随机性建模,利用粒子群算法,计算得到三个微网的优化程序
- CListTextElementUI支持按列设置颜色:通过SetTextColor或者IListCallbackUI设置
- 在Python上用openSMILE提取 eGeMAPS 情绪特征集
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈