shapefactoryimplementation.java
来自「著名的uncle Bob的Agile software development的」· Java 代码 · 共 14 行
JAVA
14 行
public class ShapeFactoryImplementation implements ShapeFactory
{
public Shape make(String shapeName) throws Exception
{
if (shapeName.equals("Circle"))
return new Circle();
else if (shapeName.equals("Square"))
return new Square();
else
throw new Exception("ShapeFactory cannot create " + shapeName);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?