静止的流水的学习日志
静止的流水
全部博文(210)
Windows(1)
Linux(31)
2011年(34)
2010年(121)
2009年(37)
2008年(18)
cynthia
wojiuzhu
jd_lzh
鄙人姓王
Jack_Tan
fanbiubi
猜我咯
aaccp1
chrisy52
分类: Java
2011-03-21 15:52:09
package com.utstar.pattern.factorymethod;public class ExportFile implements Export{ public void export(String s){ System.out.println(s); }}
package com.utstar.pattern.factorymethod;public class ExporDb implements Export{ public void export(String s){ System.out.println(s); }}
package com.utstar.pattern.factorymethod;public class ExportDbOperate extends ExportOperate{ public Export factoryMethod(){ return new ExporDb(); }}
package com.utstar.pattern.factorymethod;public class ExportFileOperate extends ExportOperate{ public Export factoryMethod(){ return new ExportFile(); }}
package com.utstar.pattern.factorymethod;public interface Export { public void export(String s);}
package com.utstar.pattern.factorymethod;public abstract class ExportOperate{ public abstract Export factoryMethod(); public void operate(String s){ factoryMethod().export(s); }}
package com.utstar.pattern.factorymethod;public class TextFactoryMethod{ public static void main(String args[]){ ExportOperate test = new ExportDbOperate(); test.operate("Hello world!"); test = new ExportFileOperate(); test.operate("hello world!"); }}
上一篇:java设计模式-策略模式(九)
下一篇:Java常见设计模式应用场景
登录 注册