---
title: "设计模式快速参考－工厂方法模式"
author: "gurudk"
date: "2008-12-06T06:43:37Z"
tags: ["Apple", "设计模式"]
slug: "untitled"
draft: false
lastmod: "2008-12-06T06:43:37Z"
id: 288028
url: "https://gurudk.iteye.com/blog/288028"
---

```
interface IFruitFactory{
   puhlic Fruit getFruit();
}
class AppleFactory implements IFruitFactory{
   public Fruit getFruit(){
      //生产苹果
      return new Apple();
   }
}
```

 

**Client：**

 

```
IFruitFactory factory = new AppleFactory();
Fruit fruit = new factory.getFruit();
```