【大话设计模式】简单工厂模式
作者:互联网
简单工厂模式
运算类
public class Operation
{
private double _numberA = 0;
private double _numberB = 0;
public double NumberA
{
get { return _numberA; }
set { _numberA = value; }
}
public double NumberB
{
get { return _numberB; }
set { _numberB = value; }
}
public virtual double GetResult()
{
double result = 0;
return result;
}
}
工厂类
客户端
Operation oper;
oper = OperationFactory.createOperate("+");
oper.NumberA = 1;
oper.NumberB = 2;
double result = oper.GetResult();
标签:oper,return,numberA,double,大话,工厂,numberB,设计模式,public 来源: https://blog.csdn.net/qq1047262678/article/details/117625507