📄 commandfactory.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package ui;import exception.NoExistsCommandException;/** * 用于生产命令对象的工厂 * @author zouhao */public class CommandFactory { private static CommandFactory instance = null; /** * 此方法是为了实现CommandFactory的Singleton * @return */ public static synchronized CommandFactory getInstance() { if (instance==null) { instance=new CommandFactory(); } return instance; } /** * 实现命令选择并动态生成相应对象 * @param which 选择输入 * @return 生成的命令对象 */public static Command factory(String which) { try{ if (which.equalsIgnoreCase("register")) { return new RegisterCommand(); } else if (which.equalsIgnoreCase("add")) { return new AddCommand(); } else if (which.equalsIgnoreCase("delete")) { return new DeleteCommand(); } else if (which.equalsIgnoreCase("query")) { return new QueryCommand(); } else if (which.equalsIgnoreCase("clear")) { return new ClearCommand(); } else if (which.equalsIgnoreCase("batch")) { return new BatchCommand(); } else if (which.equalsIgnoreCase("help")) { return new HelpCommand(); } else { throw new NoExistsCommandException(); } } catch(NoExistsCommandException e){} return null; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -