工厂方法模式
PersonAction.java
public interface PersonAction { |
WomanEat.java
public class WomanEat implements PersonAction { |
ManEat.java
public class ManEat implements PersonAction { |
Provider.java
public interface Provider { |
WomanFactory .java
public class WomanFactory implements Provider { |
ManFactory.java
public class ManFactory implements Provider { |
具体使用如下:
ManFactory manFactory = new ManFactory(); |
评论