コード例 #1
0
ファイル: StartUp.cs プロジェクト: svetlyoek/DB
        public static void Main(string[] args)
        {
            var modifyPrice = new ModifyPrice();

            var phone = new Product("Phone", 250.50m);

            var laptop = new Product("Laptop", 780);

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

            Execute(laptop, modifyPrice, new ProductCommand(laptop, PriceAction.Decrease, 200));
        }
コード例 #2
0
        public static void Run()
        {
            var modifyPrice = new ModifyPrice();
            var product     = new Product("Phone", 500);

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

            Console.WriteLine(product);

            modifyPrice.UndoActions();
            Console.WriteLine(product);
        }
コード例 #3
0
        public static void Main(string[] args)
        {
            var modifyPrice = new ModifyPrice();

            var product = new Product("iPhone", 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);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: SDP-SPIII-2020/sample-code
        public static void Main(string[] args)
        {
            var modifyPrice = new ModifyPrice();
            var product     = new Product("Tablet computer", 500.50m);

            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Increase, 100m));
            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Decrease, 5m));
            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Increase, 75m));

            Console.WriteLine(product);
            Console.WriteLine(modifyPrice.ListCommands());

            modifyPrice.UndoActions();
            Console.WriteLine(product);
            Console.WriteLine(modifyPrice.ListCommands());
        }
コード例 #5
0
 private static void Execute(Product product, ModifyPrice modifyPrice, ProductCommand productCommand)
 {
     modifyPrice.SetCommand(productCommand);
     modifyPrice.Invoke();
 }