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();
    }
    

      

  • 相关阅读:
    [LeetCode] Largest Number At Least Twice of Others 至少是其他数字两倍的最大数
    [LeetCode] Cut Off Trees for Golf Event 为高尔夫赛事砍树
    [LeetCode] Kth Smallest Number in Multiplication Table 乘法表中的第K小的数字
    [LeetCode] 746. Min Cost Climbing Stairs 爬楼梯的最小损失
    [LeetCode] Prefix and Suffix Search 前后缀搜索
    [LeetCode] Strange Printer 奇怪的打印机
    VMPlayer Ubuntu 16.04 Copy and Paste with Host 主机与宿机之间的复制粘贴
    Solve Error: "errcode": 85005, "errmsg": "appid not bind weapp hint"
    [LeetCode] Find Smallest Letter Greater Than Target 找比目标值大的最小字母
    [LeetCode] 743. Network Delay Time 网络延迟时间
  • 原文地址:https://www.cnblogs.com/tszr/p/12373083.html
Copyright © 2011-2022 走看看