本帖最后由 binghaiwang 于 2013-8-25 11:34 编辑
- <p>package com.itheima.design;
- public class FactoryDesign {
- public static void main(String[] args) {
-
- IFactory factory = new Factory();
- IProduct product = factory.creadteProduct();
- product.productMethod();
- }
- }
- interface IProduct{
- public void productMethod();
- }
- interface IFactory{
- public IProduct creadteProduct();
- }
- class Product implements IProduct{
- @Override
- public void productMethod() {
- System.out.println("产品");
- }
- }
- class Factory implements IFactory{
- @Override
- public IProduct creadteProduct() {
-
- return new Product();
- }
-
- }</p>
复制代码 上述是否属于抽象化工厂设计模式,如果不是,请简要说明下抽象化工厂设计模式的要点。最好附个简单代码例子(带注释)
|