예제 #1
0
        static void Main(string[] args)
        {
            var modifyPrice = new ModifyPrice();
            var product     = new Product("IPhone 7", 500);

            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Decrease, 200));
            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Increase, 100));
            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Decrease, 300));

            Console.WriteLine($"I can buy just \n{product}");
        }
예제 #2
0
        // Command is a Behavioral Design Pattern
        public static void Main(string[] args)
        {
            ModifyPrice modifyPrice = new ModifyPrice();
            Product     product     = new Product("Phone", 500);

            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Increase, 100));
            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Increase, 50));
            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Decrease, 25));

            Console.WriteLine(product);
        }
예제 #3
0
파일: StartUp.cs 프로젝트: VenziVi/SoftUni
        static void Main(string[] args)
        {
            var modifyPrice = new ModifyPrice();
            var product     = new Product("Toy", 50);


            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Increase, 10));
            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Increase, 10));
            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Decrease, 10));

            Console.WriteLine(product);
        }
예제 #4
0
        static void Main()
        {
            var modifyPrice = new ModifyPrice();
            var product     = new Product("Phone", 500);

            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Increase, 100));

            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Increase, 50));

            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Decrease, 25));

            Console.WriteLine(product);
        }
예제 #5
0
        static void Main(string[] args)
        {
            var modifyPrice = new ModifyPrice();
            var product     = new Product("Phone", 500);

            Execute(modifyPrice, new ProductIncreaseCommand(product, 100));

            Execute(modifyPrice, new ProductIncreaseCommand(product, 50));

            Execute(modifyPrice, new ProductDecreaseCommand(product, 25));

            Console.WriteLine(product);
        }
예제 #6
0
        static void Main(string[] args)
        {
            var modifyPrice = new ModifyPrice();
            var product     = new Product("Phone", 500);

            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Increase, 100));
            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Increase, 50));
            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Decrease, 2500));

            Console.WriteLine(product);
            Console.ReadLine();

            modifyPrice.UndoActions();

            Console.WriteLine(product);
            Console.ReadLine();
        }
예제 #7
0
 private static void Execute(Product product, ModifyPrice modifyPrice, ICommand productCommand)
 {
     modifyPrice.SetCommand(productCommand);
     modifyPrice.Invoke();
 }