`
yipbxx
  • 浏览: 57456 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

简单工厂模式

阅读更多

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();   
      }   
   }   
}
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics