标签:
publicclassShapeFactory{
//使用 getShape 方法获取形状类型的对象
publicShape getShape(String shapeType){
if(shapeType == null){
return null;
}
if(shapeType.equalsIgnoreCase("CIRCLE")){
returnnewCircle();
}elseif(shapeType.equalsIgnoreCase("RECTANGLE")){
returnnewRectangle();
}elseif(shapeType.equalsIgnoreCase("SQUARE")){
returnnewSquare();
}
return null;
}
}
标签:
原文地址:http://www.cnblogs.com/Doing-what-I-love/p/5621190.html