工厂模式之工厂方法模式
来源:互联网 发布:thinking in java 4th 编辑:程序博客网 时间:2024/05/19 19:13
publicinterface Product {
publicvoid getName();
}
publicclass AProduct implements Product{
publicvoid getName() {
System.out.println("I am product A");
}
}
publicclass BProduct implements Product{
publicvoid getName() {
System.out.println("I am product B");
}
}
publicinterface IFactory {
Product createProduct();
}
publicclass AFactory implements IFactory{
public Product createProduct() {
returnnew AProduct();
}
}
publicclass BFactory implements IFactory{
public Product createProduct() {
returnnew BProduct();
}
}
publicclass Test {
publicstaticvoid main(String []args){
IFactory iFactory = new AFactory();
Product product = iFactory.createProduct();
product.getName();
iFactory = new BFactory();
product = iFactory.createProduct();
product.getName();
}
}
- 工厂模式之工厂方法模式
- 工厂模式之--工厂方法模式
- 工厂模式之工厂方法模式
- 工厂模式之工厂方法模式
- 之 工厂方法模式
- 工厂模式 -- 工厂方法
- 工厂模式-工厂方法
- 工厂模式-工厂方法
- 工厂 > 工厂方法模式
- 【趣解】工厂模式之简单工厂、工厂方法模式
- JAVA设计模式之工厂模式(简单工厂模式+工厂方法模式+抽象工厂模式)
- JAVA设计模式之工厂模式(简单工厂模式+工厂方法模式+抽象工厂模式)
- JAVA设计模式之工厂模式(简单工厂模式+工厂方法模式+抽象工厂模式)
- JAVA设计模式之工厂模式(简单工厂模式+工厂方法模式+抽象工厂模式)
- JAVA设计模式之工厂模式(简单工厂模式+工厂方法模式+抽象工厂模式)
- java设计模式之工厂模式(简单工厂模式+工厂方法模式+抽象工厂模式)
- JAVA设计模式之工厂模式(简单工厂模式+工厂方法模式+抽象工厂模式)
- JAVA设计模式之工厂模式(简单工厂模式+工厂方法模式+抽象工厂模式)
- 代码流程分析二:Settings-蓝牙分析-搜索设备原理
- python下载视频
- GDB: don't know how to run
- [LeetCode] Populating Next Right Pointers in Each Node
- JS学习---(一)
- 工厂模式之工厂方法模式
- java中native方法的使用
- phaser入门教程
- jQuery_统计图插件-XML/SWF Charts
- 质数因子
- Android嵌套滑动组件相关的文章资料
- C# 微信接口之推送模版消息
- hdu5373 The shortest problem(迭代模拟+同余定理)
- Poj 1789 Truck History【最小生成树】