工厂模式代码

package com.bjsunyuhuan.test000;

public class Factory {       public static Fruit getInstance(String name){         if("apple".equals(name)){          return new Apple();         }if("orange".equals(name)){          return new Orange();         }        return null;              } }

posted @ 2017-08-03 13:49  超重语言  阅读(138)  评论(0编辑  收藏  举报