Beispiel #1
0
        static void Main(string[] args)
        {
            Stock     stock     = new Stock();
            BuyStock  buyStock  = new BuyStock(stock);
            SellStock sellStock = new SellStock(stock);
            Broker    broker    = new Broker();

            broker.TakeOrder(buyStock);
            broker.TakeOrder(sellStock);
            broker.PlaceOrders();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Stock abcStock = new Stock();

            BuyStock  buyStockOrder  = new BuyStock(abcStock);
            SellStock sellStockOrder = new SellStock(abcStock);
            Broker    broker         = new Broker();

            broker.TakeOrder(buyStockOrder);
            broker.TakeOrder(sellStockOrder);
            broker.PlaceOrders();

            Console.ReadKey();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Stock foodStock = new Stock();
            // 这两个命令都是针对 foodStock 的
            BuyStock  buyCom  = new BuyStock(foodStock);
            SellStock sellCom = new SellStock(foodStock);

            Broker broker = new Broker();

            // 命令添加到 执行列表 中去
            broker.TakeOrder(buyCom);
            broker.TakeOrder(sellCom);

            broker.Do();
        }
        static void Main(string[] args)
        {
            Stock       myStock        = new Stock("Carlsberg", 20);
            BuyStock    buyStockOrder  = new BuyStock(myStock);
            SellStock   sellStockOrder = new SellStock(myStock);
            StockBroker stockBroker    = new StockBroker();

            stockBroker.TakeOrder(buyStockOrder);
            stockBroker.TakeOrder(buyStockOrder);
            stockBroker.TakeOrder(sellStockOrder);

            stockBroker.PlaceOrders();

            Console.ReadLine();
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            StockManager stockManager = new StockManager();
            BuyStock     buyStock     = new BuyStock(stockManager);
            SellStock    sellStock    = new SellStock(stockManager);

            StockController stockController = new StockController();

            stockController.TakeOrder(buyStock);
            stockController.TakeOrder(sellStock);
            stockController.TakeOrder(buyStock);

            stockController.PlaceOrders();

            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            StockManager stockManager = new StockManager("Samsung Note 9", 10);

            BuyStock  buyStock  = new BuyStock(stockManager);
            SellStock sellStock = new SellStock(stockManager);

            StockController stockController = new StockController();

            stockController.TakeOrder(buyStock);
            stockController.TakeOrder(sellStock);
            stockController.TakeOrder(sellStock);
            stockController.RemoveOrder(sellStock);


            stockController.PlaceOrders();
        }
Beispiel #7
0
        static void Main()
        {
            Console.WriteLine("Command Patter [Start]");

            var stock = new Stock();

            var sellObject = new SellStock(stock);
            var buyObject = new BuyStock(stock);

            var broker = new Broker();
            broker.TakeOrder(sellObject);
            broker.TakeOrder(buyObject);
            broker.TakeOrder(buyObject);
            broker.TakeOrder(sellObject);

            broker.PlaceOrder();

            Console.WriteLine("Command Patter [End]");
            Console.Read();
        }