
package com.Shapes;
public class Shapes {
public static void main(String[] args){
/*Shape shape = new Shape();
Shape roundness = new Roundness();
Shape square = new Square();
Shape rhombus = new Rhombus();
shape.type();
shape.draw();
roundness.type();
roundness.draw();
square.type();
square.draw();
rhombus.type();
rhombus.draw();*/
Shape[] A = new Shape[4];
A[0] = new Shape();
A[1] = new Roundness();
A[2] = new Square();
A[3] = new Rhombus();
for(Shape s : A){
s.type();
s.draw();
}
}
}
class Shape{
public void type(){
System.out.print("超类爸爸:");
}
public void draw(){
System.out.println("我是楼下所有人的爸爸");
}
}
class Roundness extends Shape{
public void type(){
System.out.print("圆形:");
}
public void draw(){
System.out.println("我似鸽圆,莫得感情,也莫得钱");
}
}
class Square extends Shape{
public void type(){
System.out.print("方形:");
}
public void draw(){
System.out.println("讲真的我现在有点方");
}
}
class Rhombus extends Shape{
public void type(){
System.out.print("菱形:");
}
public void draw() {
System.out.println("菱形(冷漠)");
}
}





近期评论