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

在线视频网站如何制作网络营销应该这样做

在线视频网站如何制作,网络营销应该这样做,wordpress 导航栏搜索,网络运维必备知识1、模式标准 模式名称#xff1a;策略模式 模式分类#xff1a;行为型 模式意图#xff1a;定义一系列的算法#xff0c;把它们一个个封装起来#xff0c;并且使它们可以相互替换。此模式使得算法可以独立于使用它们的客户而变化 结构图#xff1a; 适用于#xff1…1、模式标准 模式名称策略模式 模式分类行为型 模式意图定义一系列的算法把它们一个个封装起来并且使它们可以相互替换。此模式使得算法可以独立于使用它们的客户而变化 结构图 适用于 1、许多相关的类仅仅是行为有异。“策略”提供了一种用多个行为中的一个行为来配置一个类的方法。 2、需要使用一个算法的不同变体。例如定义一些反映不同空间的空间/时间权衡的算法当这些变体实现为一个算法的类层次时可以使用策略模式。 3、算法使用客户不应该知道的数据。可使用策略模式以避免暴露复杂的、与算法相关的数据结构。 4、一个类定义了多种行为,并且这些行为在这个类的操作中以多个条件语句的形式出现,将相关的条件分支移入它们各自的 Strategy 类中以代替这些条件语句。  2、分析与设计   策略和桥接模式看起来可能非常相似但策略模式是行为型桥接模式是结构型。策略模式是直接引用实现类而桥接模式是引用一个实现类的接口。当前策略模式关键是可以相互替换算法。接下来把我们曾经用过的武器替换来举例修改一下我们的意图 意图定义一系列的算法(武器)把它们一个个封装起来并且使它们可以相互替换。 3、开始打造 // 武器接口 export interface IWeapon {useWeapon(): void; }// 剑 export class Sword implements IWeapon {useWeapon(): void {console.log(用剑进行攻击);} }// 斧头 export class Axe implements IWeapon {useWeapon(): void {console.log(用斧头进行攻击);} } // 弓 export class Bow implements IWeapon {useWeapon(): void {console.log(用弓箭进行攻击);} }// 近程攻击 export class MeleeAttack implements IAttackStrategy {attack(weapon: IWeapon): void {console.log(进行近程攻击:);weapon.useWeapon();} } 【优化】结合前面的桥接模式的攻击方式我们将攻击系统升级一下 // 攻击方式接口 export interface IAttackStrategy {attack(weapon: IWeapon): void; }// 近程攻击 export class MeleeAttack implements IAttackStrategy {attack(weapon: IWeapon): void {console.log(进行近程攻击:);weapon.useWeapon();} }// 远程攻击 export class RangedAttack implements IAttackStrategy {attack(weapon: IWeapon): void {console.log(进行远程攻击:);weapon.useWeapon();} }// 武器接口 export interface IWeapon {useWeapon(): void; }// 剑 export class Sword implements IWeapon {useWeapon(): void {console.log(用剑进行攻击);} }// 斧头 export class Axe implements IWeapon {useWeapon(): void {console.log(用斧头进行攻击);} } // 弓 export class Bow implements IWeapon {useWeapon(): void {console.log(用弓箭进行攻击);} }// 抽象战斗者 export abstract class Fighter {protected attackStrategy: IAttackStrategy;protected weapon: IWeapon;constructor(attackStrategy: IAttackStrategy, weapon: IWeapon) {this.attackStrategy attackStrategy;this.weapon weapon;}attack(): void {this.attackStrategy.attack(this.weapon);}// 更换武器的方法setWeapon(weapon: IWeapon): void {this.weapon weapon;} }// 骑兵 export class Cavalry extends Fighter {constructor(attackStrategy: IAttackStrategy, weapon: IWeapon) {super(attackStrategy, weapon);} }// 弓箭手 export class Archer extends Fighter {constructor(attackStrategy: IAttackStrategy, weapon: IWeapon) {super(attackStrategy, weapon);} } 4、开始使用 export class UnitItem extends Component implements IItem, IUnitItem {ad: number 100;mp: number 0;role: Fighter;private currentState: IUnitState null;accept(visitor: IAttackVisitor) {visitor.visitUnitItem(this)}setRole(role: Fighter): void {this.role role;}setWeapon(weapon: IWeapon) {this.role.setWeapon(weapon)}..... } let unitItem001 xhgame.itemFactory.createUnitItem(kuloubing, UnitType.UnitSpine)let unitItem002 xhgame.itemFactory.createUnitItem(kuloubing, UnitType.UnitSpine)unitItem001.idle()unitItem002.idle()const sword new Sword();const bow new Bow();const axe new Axe();unitItem001.setRole(new Cavalry(new MeleeAttack(), sword));console.log(unitItem001(骑兵-近程)使用【剑】对unitItem002发起了攻击)unitItem001.attack(unitItem002)// 更换骑兵的武器为斧头unitItem001.setWeapon(axe);console.log(unitItem001(骑兵-近程)使用【斧头】对unitItem002发起了攻击)unitItem001.attack(unitItem002);unitItem002.setRole(new Cavalry(new RangedAttack(), bow));console.log(unitItem002(骑兵-远程)使用【弓】对unitItem001发起了攻击)unitItem002.attack(unitItem001) 总结桥接模式在构建时定好攻击方式策略模式在行为中使用不同的武器。
http://www.zqtcl.cn/news/536340/

相关文章:

  • 一个中介平台网站的建设费wordpress 文章列表只显示标题
  • 网站建设包括两个方面聊城建设路小学网站
  • 怎么样做一个自己的网站遵义软件制作平台
  • 推广网站实例建设厅的证在哪里查询
  • 分类网站建设方案做学校教务处网站
  • 如何做链接淘宝客的网站只做画册的网站
  • docker可以做网站吗专业的营销型网站
  • 重庆市建设工程安全网站上海制造网站公司
  • 咨询网站公司建设计划书安卓软件开发软件
  • 手机网站建设文章直播平台开发多少钱
  • 站长综合查询工具常用的网站开发语言有哪些
  • 免费网站看v片在线第一次做乌市seo网络营销流程
  • 社交网站模板下载柬埔寨网赌网站开发
  • 网站开发合同是否要交印花税杭州集团网站建设
  • 企业网站建设排名资讯一个公司做两个网站可以吗
  • 简单门户网站开发灰色行业seo大神
  • 网站开发学那种语言外贸推广网站建设
  • 公司网站建设及推广中国优秀企业网站欣赏
  • 个人代做网站建设京东类的网站需要什么流程
  • 建设一个地方门户网站厦门网站开发排名
  • 网站建设公司广告标题语网站设计主题有哪些
  • 网站推广方式主要通过做网站所需的知识技能
  • 我想在阿里巴巴网站开店_怎么做app建设网站公司
  • 西安做百度网站的制作网站公司选 择乐云seo
  • 网站优化建设河南手机模拟器
  • 网站建设运维标准深圳企业vi设计公司
  • 做网站怎么挣钱中小型企业网站建设
  • 深圳如何搭建建网站学校网站的建设与应用
  • 免费推广网站入口2023燕wordpress看图插件
  • 网站做不做301四川省住建设厅网站