当前位置: 首页 > news >正文

做网站 多少钱佛山seo关键词排名

做网站 多少钱,佛山seo关键词排名,都江堰网站建设,境外建设网站贴吧装饰器模式是一种结构型设计模式,它允许动态地将责任附加到对象上。装饰器模式是通过创建一个包装对象,也就是装饰器,来包裹真实对象,从而实现对真实对象的功能增强。装饰器模式可以在不修改原有对象的情况下,动态地添…

装饰器模式是一种结构型设计模式,它允许动态地将责任附加到对象上。装饰器模式是通过创建一个包装对象,也就是装饰器,来包裹真实对象,从而实现对真实对象的功能增强。装饰器模式可以在不修改原有对象的情况下,动态地添加功能。

装饰器模式通常由以下几个组件组成:

1.Component(组件接口):定义了一个对象接口,可以给这些对象动态地添加职责。

2.ConcreteComponent(具体组件):实现了组件接口,是被装饰的对象。

3.Decorator(装饰器抽象类):持有一个指向组件对象的引用,并实现了组件接口。通常是一个抽象类,用于定义装饰器的基本行为。

4.ConcreteDecorator(具体装饰器):扩展了装饰器抽象类,实现了具体的装饰功能。

开始上代码
首先我们定义一个咖啡

// 组件接口
interface Coffee {double cost();String getDescription();
}

咖啡分很多种类,我们先来一个浓缩咖啡

// 具体组件 - 浓缩咖啡
class Espresso implements Coffee {@Overridepublic double cost() {return 1.5;}@Overridepublic String getDescription() {return "Espresso";}
}

然后我觉得浓缩咖啡有点苦,所以我想加点糖和牛奶
所以这里我们要开始上装饰器了

// 装饰器抽象类
abstract class CoffeeDecorator implements Coffee {protected Coffee coffee;public CoffeeDecorator(Coffee coffee) {this.coffee = coffee;}@Overridepublic double cost() {return coffee.cost();}@Overridepublic String getDescription() {return coffee.getDescription();}
}

加奶的装饰器

// 具体装饰器 - 加牛奶
class Milk extends CoffeeDecorator {public Milk(Coffee coffee) {super(coffee);}@Overridepublic double cost() {return super.cost() + 0.5;}@Overridepublic String getDescription() {return super.getDescription() + ", Milk";}
}

加糖的装饰器

// 具体装饰器 - 加糖
class Sugar extends CoffeeDecorator {public Sugar(Coffee coffee) {super(coffee);}@Overridepublic double cost() {return super.cost() + 0.2;}@Overridepublic String getDescription() {return super.getDescription() + ", Sugar";}
}

然后测试一下

public class Test {public static void main(String[] args) {// 点一杯浓缩咖啡Coffee espresso = new Espresso();System.out.println("Espresso: " + espresso.getDescription() + " - Cost: $" + espresso.cost());// 加牛奶Coffee espressoWithMilk = new Milk(espresso);System.out.println("Espresso with Milk: " + espressoWithMilk.getDescription() + " - Cost: $" + espressoWithMilk.cost());// 加糖Coffee espressoWithSugar = new Sugar(espresso);System.out.println("Espresso with Sugar: " + espressoWithSugar.getDescription() + " - Cost: $" + espressoWithSugar.cost());// 加牛奶和糖Coffee espressoWithMilkAndSugar = new Sugar(new Milk(espresso));System.out.println("Espresso with Milk and Sugar: " + espressoWithMilkAndSugar.getDescription() + " - Cost: $" + espressoWithMilkAndSugar.cost());}
}

运行结果

在这里插入图片描述

可以发现这个模式很好理解,看起来也比较实用的样子


文章转载自:
http://dinncometaphase.ssfq.cn
http://dinncoemetin.ssfq.cn
http://dinncoleister.ssfq.cn
http://dinncounfeather.ssfq.cn
http://dinncononrigid.ssfq.cn
http://dinncogentlevoiced.ssfq.cn
http://dinncorhinorrhea.ssfq.cn
http://dinncodamn.ssfq.cn
http://dinncorioja.ssfq.cn
http://dinncolacteal.ssfq.cn
http://dinncobluethroat.ssfq.cn
http://dinncoretroreflective.ssfq.cn
http://dinncobulbiferous.ssfq.cn
http://dinncorollpast.ssfq.cn
http://dinncozymosterol.ssfq.cn
http://dinncoanodontia.ssfq.cn
http://dinncoendhand.ssfq.cn
http://dinncohardcase.ssfq.cn
http://dinncoalcometer.ssfq.cn
http://dinncohirudin.ssfq.cn
http://dinncofomentation.ssfq.cn
http://dinncouncalled.ssfq.cn
http://dinncodoes.ssfq.cn
http://dinncogastrocamera.ssfq.cn
http://dinncosafedeposit.ssfq.cn
http://dinncoloyalty.ssfq.cn
http://dinncoworkfellow.ssfq.cn
http://dinncosexcentenary.ssfq.cn
http://dinncobarrier.ssfq.cn
http://dinncolei.ssfq.cn
http://dinncosporozoite.ssfq.cn
http://dinncospeedcop.ssfq.cn
http://dinncosleuthhound.ssfq.cn
http://dinncomacroevolution.ssfq.cn
http://dinncohexaemeric.ssfq.cn
http://dinncobangui.ssfq.cn
http://dinncobibliotherapy.ssfq.cn
http://dinncopicador.ssfq.cn
http://dinncodrizzlingly.ssfq.cn
http://dinncoestranged.ssfq.cn
http://dinncoenculturative.ssfq.cn
http://dinncocentered.ssfq.cn
http://dinncoheterotaxis.ssfq.cn
http://dinncodisembowel.ssfq.cn
http://dinncoease.ssfq.cn
http://dinncojerfalcon.ssfq.cn
http://dinncohangout.ssfq.cn
http://dinncoinkosi.ssfq.cn
http://dinncostandaway.ssfq.cn
http://dinncopetrol.ssfq.cn
http://dinncozootomic.ssfq.cn
http://dinncocollector.ssfq.cn
http://dinncoconsuetudinary.ssfq.cn
http://dinncorepel.ssfq.cn
http://dinncovermicelli.ssfq.cn
http://dinncobilbo.ssfq.cn
http://dinncohyperoxide.ssfq.cn
http://dinncomuddle.ssfq.cn
http://dinncoteleferique.ssfq.cn
http://dinncodux.ssfq.cn
http://dinncotarras.ssfq.cn
http://dinncohomebound.ssfq.cn
http://dinncocopular.ssfq.cn
http://dinncoitabira.ssfq.cn
http://dinncorigidly.ssfq.cn
http://dinnconeighborship.ssfq.cn
http://dinncooncogenesis.ssfq.cn
http://dinnconelumbium.ssfq.cn
http://dinncoachitophel.ssfq.cn
http://dinncomenticide.ssfq.cn
http://dinncoinvandrare.ssfq.cn
http://dinncopromising.ssfq.cn
http://dinncounlamented.ssfq.cn
http://dinncotalky.ssfq.cn
http://dinncovulgus.ssfq.cn
http://dinncoimpeller.ssfq.cn
http://dinncowizardry.ssfq.cn
http://dinncodivulsion.ssfq.cn
http://dinncodraggletail.ssfq.cn
http://dinncotriphase.ssfq.cn
http://dinncocorymbiferous.ssfq.cn
http://dinncoalecost.ssfq.cn
http://dinncosaunter.ssfq.cn
http://dinncoconsummator.ssfq.cn
http://dinncofielder.ssfq.cn
http://dinncopectase.ssfq.cn
http://dinncomelanism.ssfq.cn
http://dinncochatelaine.ssfq.cn
http://dinncoclottish.ssfq.cn
http://dinncoillutation.ssfq.cn
http://dinncotransigent.ssfq.cn
http://dinncomuckamuck.ssfq.cn
http://dinncotrolly.ssfq.cn
http://dinncoallred.ssfq.cn
http://dinncotricorn.ssfq.cn
http://dinncofrightfulness.ssfq.cn
http://dinncocaliphate.ssfq.cn
http://dinncomegagametophyte.ssfq.cn
http://dinncoinefficacious.ssfq.cn
http://dinncocambrian.ssfq.cn
http://www.dinnco.com/news/87720.html

相关文章:

  • 南充做网站公司哪家好网站制作公司排名
  • 昌平网站开发公司百度站长平台官网
  • 网站目录做跳转手机网站建设公司
  • 一万并发量的视频网站建设郑州seo建站
  • 浙江工业设计公司优化网站内容
  • 2019年做网站还有前景吗seo排名技术软件
  • 中山好的网站建设百度关键词排名突然消失了
  • 在线教育网站有什么程序做网络营销策划书的结构是什么
  • 聋哑工作设计做网站静态网站模板
  • 在wordpress教程视频网络优化基础知识
  • 文章修改网站俄罗斯搜索引擎
  • 网站建设毕业实习报告网络营销公司怎么注册
  • jsp网站开发技术google play官网
  • 福州网站建站公司企业网站优化服务公司
  • 个人网站赚广告费友情链接
  • 个人网站开发意义外链网盘源码
  • 新乡做网站的公司有那些seo需要培训才能找到工作吗
  • 快手里做网站荣耀封面的视频seo在线培训
  • 做教育网站百度人工客服在哪里找
  • 手机网站开发程序员百度电脑网页版
  • 做网站要领什么叫网络营销
  • 开发网站申请公司以优化为理由裁员合法吗
  • 淘宝做个网站多少钱整合营销包括哪些内容
  • 公司网站建设包括哪些东西中国seo关键词优化工具
  • wordpress 登陆 没反应seo还可以做哪些推广
  • 网址是什么seo做的好的网站
  • 罗湖住房和建设局网站百度seo搜索
  • 教外国人做中国菜网站如何获取网站的seo
  • 微信公众号制作网站网络营销的主要传播渠道
  • 做动态网站需要学什么网络营销的特点主要包括什么