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

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

本文简介:

public interface Carnivore{

            public void Eat(Herbivore h);

}

 

 

//Product

public class Wildebeest implements Herbivore{

}

 

public class Lion implements Carnivore{

            public void Eat(Herbivore h){

                        System.out.println(“Lion eats “ +h.getName());

            }                     

}

 

public class Bison implements Herbivore{

}

 

public class Wolf implements Carnivore{

            public void Eat(Herbivore h){

                        System.out.println(“Wolf eats “ +h.getName());

            }

}

 

//Client

public class AnimalWorld{

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

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

go top