public class Shape
{
Shape show()
{
return this;
}
}
public class Circle extends Shape
{
public Shape show()
{
System.out.println("一个半径为1的圆形");
return this;
}
}
public class Triangle extends Shape
{
public Shape show()
{
System.out.println("一个长为3宽为2的矩形");
return this;
}
}
public class Square extends Shape
{
public Shape show()
{
System.out.println("一个边长为2的正方形");
return this;
}
}
public class Text
{
public static void main(String[] args)
{
Shape a=new Circle();
Shape b=new Triangle();
Shape c=new Square();
int i=Scanner s=new Scanner(System.in);
if(i==0)
{
a.show();
}
else if(i==1)
{
b.show();
}
else if(i==2)
{
c.show();
}
else System.out.println("error");
}
}