Exemple #1
0
        static void Main(string[] args)
        {
            InitProducts();

            StandartSummerCost standartSummer = new StandartSummerCost();

            InitDiscounts(standartSummer);

            // Тут типо распологается проверка есть ли у текущего пользователя ДР и возможно другие условия
            // Но сейчас пока просто bool переменная
            bool userBirthday = true;

            if (userBirthday)
            {
                Dictionary <int, double> discountRanges = new Dictionary <int, double>();
                discountRanges.Add(1, 0.20);
                standartSummer.AddDiscount(CreatorDiscounts.getInstance().CreateDiscountOnAll(new string[] {}, discountRanges));
            }

            CalculeterCost a = new CalculeterCost(standartSummer);

            AddProductInBatscet(a);
            Console.WriteLine(a.GetSumCost());

            Console.Read();
        }
Exemple #2
0
        static void InitDiscounts(StandartSummerCost standartSummer)
        {
            standartSummer.AddDiscount(CreatorDiscounts.getInstance().CreateDiscountOnAB());

            standartSummer.AddDiscount(CreatorDiscounts.getInstance().CreateDiscountOnSet(new string[] { "A", "B" }, 0.1));
            standartSummer.AddDiscount(CreatorDiscounts.getInstance().CreateDiscountOnSet(new string[] { "D", "E" }, 0.05));
            standartSummer.AddDiscount(CreatorDiscounts.getInstance().CreateDiscountOnSet(new string[] { "E", "F", "G" }, 0.05));

            standartSummer.AddDiscount(CreatorDiscounts.getInstance().CreateDiscountOnSupplement(new string[] { "A" }, new string[] { "K", "L", "M" }, 0.05));

            Dictionary <int, double> discountRanges = new Dictionary <int, double> ();

            discountRanges.Add(3, 0.05);
            discountRanges.Add(4, 0.1);
            discountRanges.Add(5, 0.2);
            standartSummer.AddDiscount(CreatorDiscounts.getInstance().CreateDiscountOnAll(new string[] { "A", "C" }, discountRanges));
        }