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

```
abstract class Fruit{
}


class Apple extends Fruit{
}


class Orange extends Fruit{
}


class FruitFactory{
   pulic static Fruit getFruit(String fruitType){
      if (“apple” == fruitType){
         return new Apple();
      } else if (“orange” == fruitType) {
         return new Orange();
      }
   }
}
```