小菜编程成长记(五 体会简单工厂模式的美妙)
[1] 小菜编程成长记(五 体会简单工厂模式的美妙)
[2] 小菜编程成长记(五 体会简单工厂模式的美妙)
[3] 小菜编程成长记(五 体会简单工厂模式的美妙)
[4] 小菜编程成长记(五 体会简单工厂模式的美妙)
[2] 小菜编程成长记(五 体会简单工厂模式的美妙)
[3] 小菜编程成长记(五 体会简单工厂模式的美妙)
[4] 小菜编程成长记(五 体会简单工厂模式的美妙)
系列文章导航:
小菜编程成长记(九 会修电脑不会修收音机?——聊设计模式原则)
小菜编程成长记(十一 无熟人难办事?——聊设计模式迪米特法则)
小菜编程成长记(十三 设计模式不能戏说!设计模式怎就不能戏说?)
/**//// <summary>
/// 加法类
/// </summary>
class OperationAdd : Operation
{
public override double GetResult()
{
double result = 0;
result = NumberA + NumberB;
return result;
}
}
/**//// <summary>
/// 减法类
/// </summary>
class OperationSub : Operation
{
public override double GetResult()
{
double result = 0;
result = NumberA - NumberB;
return result;
}
}
/**//// <summary>
/// 乘法类
/// </summary>
class OperationMul : Operation
{
public override double GetResult()
{
double result = 0;
result = NumberA * NumberB;
return result;
}
}
/**//// <summary>
/// 除法类
/// </summary>
class OperationDiv : Operation
{
public override double GetResult()
{
double result = 0;
if (NumberB==0)
throw new Exception("除数不能为0。");
result = NumberA / NumberB;
return result;
}
}
/// 加法类
/// </summary>
class OperationAdd : Operation
{
public override double GetResult()
{
double result = 0;
result = NumberA + NumberB;
return result;
}
}
/**//// <summary>
/// 减法类
/// </summary>
class OperationSub : Operation
{
public override double GetResult()
{
double result = 0;
result = NumberA - NumberB;
return result;
}
}
/**//// <summary>
/// 乘法类
/// </summary>
class OperationMul : Operation
{
public override double GetResult()
{
double result = 0;
result = NumberA * NumberB;
return result;
}
}
/**//// <summary>
/// 除法类
/// </summary>
class OperationDiv : Operation
{
public override double GetResult()
{
double result = 0;
if (NumberB==0)
throw new Exception("除数不能为0。");
result = NumberA / NumberB;
return result;
}
}