コード例 #1
0
ファイル: Client.cs プロジェクト: thomerson/DesignPattern
        void Test()
        {
            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();
        }
コード例 #2
0
        /// <summary>
        /// 步骤 5 使用 Broker 类来接受并执行命令。
        /// </summary>
        /// <param name="args"></param>
        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();
        }