示例#1
0
        /// <summary>
        /// Method used to create total price for the products.
        /// </summary>
        /// <param name="products">The cart items.</param>
        /// <returns>Returns total price.</returns>
        public int CalculateTotalPrice(List <char> products)
        {
            try
            {
                if (cartEngine != null)
                {
                    //// Step 1 : Apply promotions for orders
                    if (promotionEngine != null)
                    {
                        int promotionTotalPrice = promotionEngine.ApplyPromotion(products);

                        //// Calculate billing for the non promoted items.
                        int cartProductTotalPrice = cartEngine.Calculate(promotionEngine.GetNonPromotedItems(products));
                        return(promotionTotalPrice + cartProductTotalPrice);
                    }

                    //// step 2 : Calculate non promotion type if it is exists else calculate complete orders
                    return(cartEngine.Calculate(products));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(0);
        }