抽象工厂模式(Abstract Factory)[6]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

            private Herbivore herbivore;

            private Carnivore carnivore;

            public AnimalWorld(ContinentFactory factory){

                        carnivore=factory. CreateCarnivore();

                        herbivore=factory. CreateHerbivore();

            }

            //Mehtods

            public void RunFoodChain(){

                        carnivore.Eat(herbivore);

            }

            public static void  main(String[] args){

                        AnimalWorld world=new AnimalWorld(new AfricaFactory());

                        world.RunFoodChain();

                       

                        world=new AnimalWorld(new AmericaFactory());

本文关键:抽象工厂模式(Abstract Factory)
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top