⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commandfactory.java

📁 Java编写个人日程管理工具, 具有添加编辑日程和自动适应功能, 程序包含完整的Document和测试运行环境
💻 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 + -