首页 > 学院 > 开发设计 > 正文

简单工厂模式

2019-11-14 10:17:03
字体:
来源:转载
供稿:网友

public class OperationFactory{    public static Operation createOperate( string operate)    {        Operation oper = null;        switch (operate)        {			case “+”:				oper = new OperationAdd();				break;			case “-”:				oper = new OperationSub();				break;			case “*”:				oper = new OperationMul();				break;			case “/”:				oper = new OperationDiv();				break;        }     }}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表