zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然轻量级JAVA EE企业应用开发Struts2Sping4Hibernate整合开发学习笔记:企业应用开发的思考和策略_Bridge

    /**
     * Description:
     * <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
     * <br/>Copyright (C), 2001-2016, Yeeku.H.Lee
     * <br/>This program is protected by copyright laws.
     * <br/>Program Name:
     * <br/>Date:
     * @author  Yeeku.H.Lee kongyeeku@163.com
     * @version  1.0
     */
    
    public class PepperySytle implements Peppery
    {
        // 实现"辣味"风格的方法
        public String style()
        {
            return "辣味很重,很过瘾...";
        }
    }
    /**
     * Description:
     * <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
     * <br/>Copyright (C), 2001-2016, Yeeku.H.Lee
     * <br/>This program is protected by copyright laws.
     * <br/>Program Name:
     * <br/>Date:
     * @author  Yeeku.H.Lee kongyeeku@163.com
     * @version  1.0
     */
    
    public class PlainStyle implements Peppery
    {
        // 实现"不辣"风格的方法
        public String style()
        {
            return "味道清淡,很养胃...";
        }
    }
    /**
     * Description:
     * <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
     * <br/>Copyright (C), 2001-2016, Yeeku.H.Lee
     * <br/>This program is protected by copyright laws.
     * <br/>Program Name:
     * <br/>Date:
     * @author  Yeeku.H.Lee kongyeeku@163.com
     * @version  1.0
     */
    
    public class PorkyNoodle extends AbstractNoodle
    {
        public PorkyNoodle(Peppery style)
        {
            super(style);
        }
        // 实现eat()抽象方法
        public void eat()
        {
            System.out.println("这是一碗稍嫌油腻的猪肉面条。"
                + super.style.style());
        }
    }
    /**
     * Description:
     * <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
     * <br/>Copyright (C), 2001-2016, Yeeku.H.Lee
     * <br/>This program is protected by copyright laws.
     * <br/>Program Name:
     * <br/>Date:
     * @author  Yeeku.H.Lee kongyeeku@163.com
     * @version  1.0
     */
    public class Test
    {
        public static void main(String[] args)
        {
            // 下面将得到“辣味”的牛肉面
            AbstractNoodle noodle1 = new BeefNoodle(
                new PepperySytle());
            noodle1.eat();
            // 下面将得到“不辣”的牛肉面
            AbstractNoodle noodle2 = new BeefNoodle(
                new PlainStyle());
            noodle2.eat();
            // 下面将得到“辣味”的猪肉面
            AbstractNoodle noodle3 = new PorkyNoodle(
                new PepperySytle());
            noodle3.eat();
            // 下面将得到“不辣”的猪肉面
            AbstractNoodle noodle4 = new PorkyNoodle(
                new PlainStyle());
            noodle4.eat();
        }
    }
    /**
     * Description:
     * <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
     * <br/>Copyright (C), 2001-2016, Yeeku.H.Lee
     * <br/>This program is protected by copyright laws.
     * <br/>Program Name:
     * <br/>Date:
     * @author  Yeeku.H.Lee kongyeeku@163.com
     * @version  1.0
     */
    
    public abstract class AbstractNoodle
    {
        // 组合一个Peppery变量,用于将该维度的变化独立出来
        protected Peppery style;
        // 每份Noodle必须组合一个Peppery对象
        public AbstractNoodle(Peppery style)
        {
            this.style = style;
        }
        public abstract void eat();
    }
    /**
     * Description:
     * <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
     * <br/>Copyright (C), 2001-2016, Yeeku.H.Lee
     * <br/>This program is protected by copyright laws.
     * <br/>Program Name:
     * <br/>Date:
     * @author  Yeeku.H.Lee kongyeeku@163.com
     * @version  1.0
     */
    
    public class BeefNoodle extends AbstractNoodle
    {
    	public BeefNoodle(Peppery style)
    	{
    		super(style);
    	}
    	// 实现eat()抽象方法
    	public void eat()
    	{
    		System.out.println("这是一碗美味的牛肉面条。"
    			+ super.style.style());
    	}
    }
    

      

    /**
     * Description:
     * <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
     * <br/>Copyright (C), 2001-2016, Yeeku.H.Lee
     * <br/>This program is protected by copyright laws.
     * <br/>Program Name:
     * <br/>Date:
     * @author  Yeeku.H.Lee kongyeeku@163.com
     * @version  1.0
     */
    public interface Peppery
    {
    	String style();
    }
    

      

  • 相关阅读:
    Shiro 学习笔记(Realm)
    Shiro 学习笔记(Authentication)
    Shiro 学习笔记(基本结构)
    POI 示例(导入,导出)
    SpringBoot 整合POI
    解决使用drf-haystack报错ImportError: cannot import name get_count
    python实现冒泡排序和插入排序
    九大排序算法总结(转)
    Djaong 数据库查询
    django session 和cookie的设置,获取和删除
  • 原文地址:https://www.cnblogs.com/tszr/p/12373083.html
Copyright © 2011-2022 走看看