📄 shapetest.java
字号:
package sample;
public class ShapeTest {
public ShapeTest() {
}
public static void main(String[] args) {
//ShapeTest shapeTest1 = new ShapeTest();
Shape[] s={new Shape(1,4),
new Rectangle(1,2,3,4),
new Circle(2,3,5)};
for(int k = 0; k < s.length; k++){
s[k].draw();
}
/*
Circle c = new Circle(1,2,3);
c.draw();
*/
}
}
class Shape{
protected int x;
protected int y;
//public Shape(){}
public Shape(int x, int y){
this.x = x;
this.y = y;
}
public void draw(){System.out.println("This is a test in shape......");}
}
class Rectangle extends Shape{
private int heigth;
private int weight;
public Rectangle(int x, int y, int w, int h){
super(x,y);
this.weight = w;
this.heigth = h;
}
public void draw(){System.out.println("This is a test in Rectangle.");}
}
class Circle extends Shape{
private int r;
public Circle(int x, int y, int r){
super(x,y);
this.r = r;
}
public void draw(){System.out.println("This is a test in Circle.");}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -