コード例 #1
0
ファイル: ThresholdDiscount.cs プロジェクト: Malven/Factory
 public decimal GetTotal( Order order )
 {
     if ( order.GetTotal() > threshold ) {
         decimal temp = order.GetTotal() * discount;
         return order.GetTotal() - temp;
     }
     else
         return order.GetTotal();
 }
コード例 #2
0
ファイル: BestForCustomer.cs プロジェクト: Malven/Factory
        public override IPriceStrategy GetTotal( Order order )
        {
            decimal maxValue = decimal.MaxValue;
            IPriceStrategy strategyToReturn = null;

            foreach ( var item in strategies ) {
                if(item.GetTotal( order ) < maxValue ) {
                    maxValue = item.GetTotal( order );
                    strategyToReturn = item;
                }
            }
            return strategyToReturn;
        }
コード例 #3
0
ファイル: PercentDiscount.cs プロジェクト: Malven/Factory
 public decimal GetTotal( Order order )
 {
     decimal temp = order.GetTotal() * discount;
     return order.GetTotal() - temp;
 }
コード例 #4
0
ファイル: Composite.cs プロジェクト: Malven/Factory
 public abstract IPriceStrategy GetTotal( Order order );