- 工厂模式
- **package com.gongchong.mo;
/**
*
* @author songli
* QQ:2734030745
* 邮箱:15850774503@163.com
* 2017年5月30日 下午2:56:34
*/
public interface ExportFileApi {
public void export(String data);
}
package com.gongchong.mo;
public class ExportDBFile implements ExportFileApi {
@Override
public void export(String data) {
// TODO Auto-generated method stub
System.out.println("dfdlkfjkld");
}
}
package com.gongchong.mo;
public abstract class ExportOperate {
public abstract ExportFileApi newExportfile();
public void export(String data){
ExportFileApi file = newExportfile();
file.export(data);
}
}
package com.gongchong.mo;
/**
*
* @author songli
* QQ:2734030745
* 邮箱:15850774503@163.com
* 2017年5月29日 下午11:32:00
*/
public class ExportOperator extends ExportOperate {
@Override
public ExportFileApi newExportfile() {
// TODO Auto-generated method stub
return new ExportDBFile();
}
}
package com.gongchong.mo;
public class Client {
public static void main(String[] args) {
// TODO Auto-generated method stub
String data = "dkfj";
ExportDBFile file = new ExportDBFile();
file.export(data);
}
}
工厂模式方法的总的来说就算让子类来写父类的实现