decimal CalculateSinglePromoted(string[] promotionTypes, ReceiptItem receiptItem) { if (promotionTypes.Length == 0) { return 0M; } decimal promoted = receiptItem.Promoted; foreach (string type in promotionTypes) { switch (type) { case "BUY_TWO_GET_ONE": ICalculatePromotion calculate = new BuyTwoGetOne(); promoted += calculate.CalculatePromoted(receiptItem); break;; } } return promoted; }
public decimal CalculatePromoted(ReceiptItem receiptItem) { int freeNumber = receiptItem.Amount/3; return freeNumber* receiptItem.Product.Price; }