コード例 #1
0
        private ICap _cap;       // 瓶盖对象

        /// <summary>
        /// 创建最终药水对象
        /// </summary>
        /// <param name="bottleColor"></param>
        /// <param name="capShape"></param>
        public void MakeProduct(string bottleColor, string capShape)
        {
            _bottle = BottleFactory.CreateBottle(bottleColor);
            _cap    = CapFactory.CreateCap(capShape);
            Console.WriteLine("准备英雄需要的瓶子和瓶盖。");
            _bottle.ShowInfo();
            _cap.ShowInfo();
            Console.WriteLine("开始往瓶子了灌入隐形药水,然后封上瓶盖。");
        }
コード例 #2
0
 /// <summary>
 /// 创建瓶盖
 /// </summary>
 /// <returns></returns>
 public override ICap CreateCap()
 {
     return(CapFactory.CreateCap("square"));
 }
コード例 #3
0
 /// <summary>
 /// 创建瓶盖
 /// </summary>
 /// <returns></returns>
 public override ICap CreateCap()
 {
     return(CapFactory.CreateCap("round"));
 }