标签:style blog color java ar div sp log on
工厂模式: public interface Cookie { public abstract void run (); } public abstract class CookieFactory { abstract Cookie create(); } public class BearCookie implements Cookie{ public void run (){ System.out.println("正在制作小熊饼干"); } } public class NumberOneFactory extends CookieFactory{ Cookie create(){ return new BearCookie(); } } public class Test { public static void main(String[] args) { CookieFactory cf=new NumberOneFactory(); Cookie c=cf.create(); c.run(); } }
标签:style blog color java ar div sp log on
原文地址:http://www.cnblogs.com/shelly0307/p/3969287.html