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(); }
/// <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(); }