using System;
namespace NotePadTest{
    interface IFactor{
        IProduct CreateIProduct();
    }
    
    interface IProduct{
        void showMethod();
    }
    
    class BaseProduct : IProduct{
        public void showMethod(){
            Console.Write(this.ToString());
            Console.Read();
        }
        
    }
    
    class ProductA : BaseProduct{
        public new void showMethod(){
            Console.Write(this.ToString() + "new");
            Console.Read();
        }
    }
    
    class ProductB : BaseProduct{
    
    }
    
    class FactorA : IFactor{
        public IProduct CreateIProduct(){
            return new ProductA();
        }
    }
    
    class FactorB : IFactor{
        public IProduct CreateIProduct(){
            return new ProductB();
        }
    }
    
    class EntryPoint{
        public static void Main(string[] args)
        {
            IFactor iFactor = new FactorA();
            IProduct iProduct = (IProduct)iFactor.CreateIProduct();
            iProduct.showMethod();
        }
    }
}

相关文章:

  • 2021-04-23
  • 2022-01-21
  • 2022-12-23
  • 2021-09-02
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案