设计模式-》外观模式

模拟下单付款 下单付款后, 库存Manager减一,钱包Manager

    public class PlayFace
    {
        private readonly GoodsManager _goodsManager;
        private readonly WalletManager _walletManager;

        public PlayFace()
        {
            _goodsManager =new GoodsManager();
            _walletManager = new WalletManager();
        }

        public void Buy()
        {
            _goodsManager.Buy();
            _walletManager.Buy();
        }
    }

    public class GoodsManager
    {
        public void Buy()
        {
            Console.WriteLine("商品下单");
        }
    }

    public class WalletManager
    {
        public void Buy()
        {
            Console.WriteLine("钱包下单");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var playFace = new PlayFace();
            playFace.Buy();
        }
    }
posted @ 2022-01-13 20:56  icxl  阅读(49)  评论(0编辑  收藏  举报