模版模式

模版模式

作者:LAMP小白  点击:1688  发布日期:2012-10-09 22:06:00  返回列表
模版模式创建了一个实施一组方法和功能的抽象对象,子类通常将这个对象作为模版用于自己的设计

其实说白了,就是抽象类里面规定了子类必须继承或实现的方法,达到统一格式的目的
mio_lt;?php
    abstract class saleItemTemplate
    {
        public $price = 0;
        public final function setPriceAdjustments()
        {
            $this-mio_gt;price += $this-mio_gt;taxAddition();
            $this-mio_gt;price += $this-mio_gt;overSizeAddition();
        }
        protected function overSizeAddition()
        {
            return 0;
        }
        abstract protected function taxAddition();
    }
    class cd extends saleItemTemplate
    {
        public $band;
        public $title;
        public function __construct($band, $title)
        {
            $this-mio_gt;band = $band;
            $this-mio_gt;title = $title;
        }
        protected function taxAddition()
        {
            return 0;
        }
    }
?mio_gt;



上一篇:字符串查询 下一篇:快递查询API
0