在上一篇博文结尾中,提到了存在的问题,那么我们通过策略模式与简单工厂结合的方式来解决上篇结尾中提到的问题。

方法很简单,我们将CashContext简单的改造一下即可

photoshop培训,电脑培训,电脑维修培训,移动软件开发培训,网站设计培训,网站建设培训

 1  class CashContext 2     { 3         CashSuper cs = null; 4         public CashContext(string type) 5         { 6             switch (type) 7             { 8                 case "正常收费": 9                     cs = new CashNormal();10                     break;11                 case "满300返100":12                     cs = new CashReturn("300", "100");13                     break;14               
        
		

网友评论