您当前的位置: 首页 >  段智华 Java

JAVA设计模式实战---工厂模式!!!

段智华 发布时间:2016-02-08 16:25:40 ,浏览量:2

JAVA设计模式实战---工厂模式!!!


package IMF;


public class DesignPatternFactoryOps {


public static void main(String[] args) {
 
        
        Fruit f=null;
       f=FruitFactory.getInstance("Pairs"); //要一个Pairs,工厂就生产一个Pairs
        if(f !=null){
          f.eat();   //Pairs的吃法
        }
        f=FruitFactory.getInstance("Apple");//要一个Apple,工厂就生产一个Apple
        if(f !=null){
          f.eat();  //Apple的吃法
        }
        
        
}

}




 


<
关注
打赏
查看更多评论

段智华

暂无认证

  • 2浏览

    0关注

    1232博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录