package javazy_0527;
public class Shape {//父类
static int width;
static int height;
Shape(int i){//构造
}
Shape(int i,int j){//构造
width=i;
height=j;
}
}
class Circle extends Shape{//圆
int r;
Circle(int r) {
super(i);
this. r=r;
}
}
class Rectangle extends Shape{//长方形
public Rectangle(int width,int height) {
// TODO Auto-generated constructor stub
super(width, height);
}
}
class Square extends Shape{//正方形
int side;
public Square(int side) {
// TODO Auto-generated constructor stub
super(i);
this.side=i;
}
}
package javazy_0527;
public class Test {
public static Shape getShape(int i) { 函数声明
if(i==1) {
Shape s1 = new Circle(1);
return s1;
}
if(i==2) {
Shape s2 = new Rectangle(2,3);;
return s2;
}
if(i==3) {
Shape s3 = new Square(2);
return s3;
}
else {
return null;
}
}
}