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

如何制作自己的网站的邮箱wordpress幻灯片图片主题

如何制作自己的网站的邮箱,wordpress幻灯片图片主题,品牌建设情况,推广网站制作Unity实现设计模式——模板方法模式 模板模式(Template Pattern)#xff0c; 指在一个抽象类公开定义了执行它的方法的模板。它的子类可以按需要重写方法实现#xff0c;但调用将以抽象类中定义的方式进行。 简单说#xff0c; 模板方法模式定义一个操作中的算法的骨架 指在一个抽象类公开定义了执行它的方法的模板。它的子类可以按需要重写方法实现但调用将以抽象类中定义的方式进行。 简单说 模板方法模式定义一个操作中的算法的骨架而将这些步骤延迟到子类中使得子类可以不改变一个算法的结构就可以重定义该算法的某些特定步骤。 注意模板方法模式和策略模式的区别 模板模式注意强调了抽象类公开定义了一个执行的模板方法而策略模式是对单个算法的封装更具有独立性 下面使用两个例子去介绍模板方法模式 1.第一个例子使用比较抽象的例子 一AbstractClass abstract class AbstractClass {public abstract void PrimitiveOperation1();public abstract void PrimitiveOperation2();// The Template methodpublic void TemplateMethod(){PrimitiveOperation1();PrimitiveOperation2();Debug.Log();} }二ConcreteClassA class ConcreteClassA : AbstractClass {public override void PrimitiveOperation1(){Debug.Log(ConcreteClassA.PrimitiveOperation1());}public override void PrimitiveOperation2(){Debug.Log(ConcreteClassA.PrimitiveOperation2());} }三ConcreteClassB class ConcreteClassB : AbstractClass {public override void PrimitiveOperation1(){Debug.Log(ConcreteClassB.PrimitiveOperation1());}public override void PrimitiveOperation2(){Debug.Log(ConcreteClassB.PrimitiveOperation2());} }四测试 public class TemplateMethodStructure : MonoBehaviour {void Start ( ){AbstractClass aA new ConcreteClassA();aA.TemplateMethod();AbstractClass aB new ConcreteClassB();aB.TemplateMethod();} }2.第二个例子使用一个三明治的制作过程来介绍 一Hoagie 三明治抽象基类 public abstract class Hoagie{public void MakeSandwich(){Debug.Log(Making new Sandwich);CutBun();if (CustomerWantsMeat()){AddMeat();}if (CustomerWantsCheese()){AddCheese();}if (CustomerWantsVegetables()){AddVegetables();}if (CustomerWantsCondiments()){AddCondiments();}WrapTheHoagie();}protected abstract void AddMeat();protected abstract void AddCheese();protected abstract void AddVegetables();protected abstract void AddCondiments();protected virtual bool CustomerWantsMeat() { return true; } // called Hookprotected virtual bool CustomerWantsCheese() { return true; }protected virtual bool CustomerWantsVegetables() { return true; }protected virtual bool CustomerWantsCondiments() { return true; }protected void CutBun(){Debug.Log(Bun is Cut);}protected void WrapTheHoagie(){Debug.Log(Hoagie is wrapped.);}}二ItalienHoagie 法式三明治 public class ItalienHoagie : Hoagie{protected override void AddMeat(){Debug.Log(Adding the Meat: Salami);}protected override void AddCheese(){Debug.Log(Adding the Cheese: Provolone);}protected override void AddVegetables(){Debug.Log(Adding the Vegetables: Tomatoes);}protected override void AddCondiments(){Debug.Log(Adding the Condiments: Vinegar);}}三VeggieHoagie 素菜三明治 public class VeggieHoagie : Hoagie{protected override void AddMeat(){}protected override void AddCheese(){}protected override void AddVegetables(){Debug.Log(Adding the Vegetables: Tomatoes);}protected override void AddCondiments(){Debug.Log(Adding the Condiments: Vinegar);}protected override bool CustomerWantsMeat() { return false; }protected override bool CustomerWantsCheese() { return false; }}四错误的方式 namespace BadExample{// this way you would have to rewrite a lot of code// especially if something changes or another class differs and does e.g. not AddMeat()public class ItalienHoagie{public void MakeSandwich(){CutBun();AddMeat();AddCheese();AddVegtables();AddCondiments();WrapHoagie();}public void CutBun(){Debug.Log(Hoagie is Cut);}public void AddMeat(){Debug.Log(Added Meat);}public void AddCheese(){Debug.Log(Added Cheese);}public void AddVegtables(){Debug.Log(Added Vegies);}public void AddCondiments(){Debug.Log(Added Condiments);}public void WrapHoagie(){Debug.Log(Wrapped Hoagie);}}}五测试 public class TemplateMethodPatternExample1 : MonoBehaviour{void Start(){Hoagie cust12Hoagie new ItalienHoagie();cust12Hoagie.MakeSandwich();Hoagie cust13Hoagie new VeggieHoagie();cust13Hoagie.MakeSandwich();}}
http://www.hkea.cn/news/14404485/

相关文章:

  • 北京网站设计策划公司wordpress物体替换纹理
  • 素材动图网站银川哪里做网站
  • 最新开的手游传奇网站怎样做化妆品网站
  • 电商网站有哪些功能搜索引擎优化简称
  • 做程序界面的网站网站托管好吗
  • 玉环建设局网站网站登录密码保存在哪里设置
  • 做3ds磁铁卡网站网站设计架构
  • 天猫设计师服务平台如何做网站搜索优化
  • 做淘客网站网站建设 .北京蓝纤
  • 大连制作网站软件下城区做网站
  • 多少钱能运营一个网站云南建设局网站
  • 天水网站seowordpress在后台文章自定义表单
  • 佛山 网站关键词优化黄骅的网站
  • 计算机网站建设好不好兰州微商城搭建
  • 三河建设厅网站北京软件外包公司排行榜
  • 做网站写代码好还是模板网站开发教程H5
  • 专题页网站小型企业网站建设公司
  • 站建设培训学校全国学校信息查询官网
  • wordpress 多站点 主站点成品人和精品人的区别在哪约
  • 建立自己的网站怎么样做WordPress网站动漫你在
  • 自己做网站 需要服务器吗江苏太仓建设局网站
  • 网域高科学校网站管理系统漏洞外贸业务员怎么开发客户
  • 网站安全检测发生告警后苏州seo专家教优化网站结构
  • 企业搭建pc端网站长兴县城乡建设局网站
  • iis 网站 端口网站伪静态好还是静态好
  • ps做设计想接私活在什么网站如何搭建网上商城
  • 南京快速建设企业网站分布式加载网站的静态
  • 西安做网站的公司地址网站什么意思
  • 网站后台怎么建设河南建设银行处理违章网站
  • 帝国cms建站实例教程企业网站建设费用计入什么科目