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

开发一个商城网站多少钱网络营销出来可以干什么工作

开发一个商城网站多少钱,网络营销出来可以干什么工作,西部数据网站管理助手,WordPress虚拟商城插件Unity实现设计模式——模板方法模式 模板模式(Template Pattern), 指在一个抽象类公开定义了执行它的方法的模板。它的子类可以按需要重写方法实现,但调用将以抽象类中定义的方式进行。 简单说, 模板方法模式定义一个操作中的算法的骨架&…

Unity实现设计模式——模板方法模式

模板模式(Template Pattern), 指在一个抽象类公开定义了执行它的方法的模板。它的子类可以按需要重写方法实现,但调用将以抽象类中定义的方式进行。
简单说, 模板方法模式定义一个操作中的算法的骨架,而将这些步骤延迟到子类中,使得子类可以不改变一个算法的结构,就可以重定义该算法的某些特定步骤。

在这里插入图片描述
注意模板方法模式和策略模式的区别
模板模式注意强调了抽象类公开定义了一个执行的模板方法,而策略模式是对单个算法的封装更具有独立性

下面使用两个例子去介绍模板方法模式:

1.第一个例子(使用比较抽象的例子)

(一)AbstractClass

abstract class AbstractClass
{public abstract void PrimitiveOperation1();public abstract void PrimitiveOperation2();// The "Template method"public 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.ds6.com.cn/news/12466.html

相关文章:

  • 大型的网站开发seo第三方点击软件
  • 做网站的设计尺寸域名注册免费
  • 电商 网站 备案今天刚刚的最新新闻
  • 怎么用自己的电脑做网站爱营销电信版下载app最新版
  • 义乌哪里有学做网站的做百度推广的公司电话号码
  • 做外贸做什么网站好seo行业
  • 个人crm百度seo最成功的优化
  • 怎么在手机上做网站搜外seo视频 网络营销免费视频课程
  • 南京网站推广价格广告点击一次多少钱
  • 做百度收录比较好的网站友链目录网
  • 网站建设的基本特点g3云推广靠谱吗
  • 宁波网站建设联系荣胜成都新闻今日最新消息
  • 溧阳网站建设公司响应式网站模板的优势
  • ps高手教学网站宁波厂家关键词优化
  • 中国做b2b外贸的网站百度seo关键词排名查询
  • 长沙建设信息网站2023年6月疫情恢复
  • 科技网站banner腾讯域名注册官网
  • 做网站手机端不做PC可以吗台州网站建设平台
  • 云主机上传wordpress汕头seo推广
  • 电子商务网站开发背景和意义优化设计五年级下册数学答案
  • vs如何做网站企业如何做网络推广
  • 杭州企业网站建设方案网络营销课程速成班
  • 网站开发老是弹广告网页制作网站
  • 网站开发报价表前端性能优化有哪些方法
  • 网站建设大约多长时间网页分析报告案例
  • 好玩的网页长沙seo排名优化公司
  • 为什么国外网站有时打不开web个人网站设计代码
  • 政府网站建设怎么做google入口
  • 如何建网站模板seo优化工具大全
  • 电脑做系统哪个网站比较好线下推广渠道和方式