コード例 #1
0
        public static void Test()
        {
            Console.WriteLine("### FactoryMethod");

            IFactory factory;

            factory = new ThinFactory();
            var kappaChan = factory.Create();

            kappaChan.Eat();

            Console.WriteLine("--- Factoryの入れ替え");

            factory = new FatFactory();
            var kappaSan = factory.Create();

            kappaSan.Eat();
        }
コード例 #2
0
ファイル: AbstractFactory.cs プロジェクト: limlimb/test
        public static void Test()
        {
            Console.WriteLine("### AbstractFactory");

            IFactory  factory;
            IKappa    kappa;
            ICucumber cucumber;

            factory  = new ThinFactory();
            kappa    = factory.kappaFactory();
            cucumber = factory.cucumberFactory();
            kappa.JikoShoukai();
            cucumber.Taste();

            Console.WriteLine("--- Factoryの入れ替え");

            factory  = new FatFactory();
            kappa    = factory.kappaFactory();
            cucumber = factory.cucumberFactory();
            kappa.JikoShoukai();
            cucumber.Taste();
        }