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

php自己做网站访问量计算每天4元代发广告

php自己做网站访问量计算,每天4元代发广告,桂林广告设计制作公司,在网站设计中 网页框架设计状态模式 介绍 设计模式定义案例问题堆积在哪里解决办法状态模式一个对象 状态可以发生改变 不同的状态又有不同的行为逻辑游戏角色 加载不同的技能 每个技能有不同的:攻击逻辑 攻击范围 动作等等1 状态很多 2 每个状态有自己的属性和逻辑每种状态单独写一个类 角色…

状态模式

介绍

设计模式定义案例问题堆积在哪里解决办法
状态模式一个对象 状态可以发生改变
不同的状态又有不同的行为逻辑
游戏角色 加载不同的技能
每个技能有不同的:攻击逻辑 攻击范围 动作等等
1 状态很多
2 每个状态有自己的属性和逻辑
每种状态单独写一个类
角色需要那个状态就加载哪一个

类图

角色: 

stateBase 抽象状态

stateA 具体状态A

stateB 具体状态B

stateC 具体状态C

FactoryState  状态工厂

代码

RoleContext

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class RoleContext
{string name;StateBase currentState = null;public RoleContext(){name = "独孤求败";}// 展示动作public void ShowAction(){if (null != currentState){currentState.Action();}}// 切换状态public void ChangeActionState(StateBase newState){currentState = newState;}
}

StateBase


public abstract class StateBase
{public abstract void Action();
}

StateA 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class StateA : StateBase
{string name = "普攻";public override void Action(){Debug.Log("释放-" + name);}
}

StateB 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class StateB : StateBase
{string name = "次元斩";public override void Action(){Debug.Log("释放-" + name);}
}

StateC

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class StateC:StateBase
{string name = "升龙击";public override void Action(){Debug.Log("释放-" + name);}
}

FactoryState

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class FactoryState
{// 单例static FactoryState  self = null;FactoryState() { }public static  FactoryState Instance(){if (null == self)self = new FactoryState();return self;}Dictionary<string, StateBase> dic = new Dictionary<string, StateBase>();// 获取实例public StateBase GetStateIns(string className){StateBase ins = null;switch (className){case "StateA":{if (false == dic.ContainsKey(className))ins = new StateA();elseins = dic[className];}break;case "StateB":{if (false == dic.ContainsKey(className))ins = new StateB();elseins = dic[className];}break;case "StateC":{if (false == dic.ContainsKey(className))ins = new StateC();elseins = dic[className];}break;default:Debug.Log("未发现该类!");break;}return ins;}
}

测试代码

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class TestZT : MonoBehaviour
{void Start(){RoleContext role = new RoleContext();// 切换技能Arole.ChangeActionState(FactoryState.Instance().GetStateIns("StateA"));role.ShowAction();// 切换技能Brole.ChangeActionState(FactoryState.Instance().GetStateIns("StateB"));role.ShowAction();// 切换技能Crole.ChangeActionState(FactoryState.Instance().GetStateIns("StateC"));role.ShowAction();}}

结果

总结

状态模式

1 是一个非常好用的 解耦合的手段, 角色不同的状态封装不同的(动作,属性,限制)

2 非常符合对修改封闭对扩展开发的原则。

3 让状态的职责更加的单一

4 也符合了依赖倒置 ,依赖了抽象

5 符合了迪米特原则,角色对状态类内部的具体实现不知道

http://www.hkea.cn/news/461703/

相关文章:

  • 我的网站模板网站建设主要推广方式
  • 国外app素材网站seo运营是做什么的
  • 企业网站seo怎么做百度帐号个人中心
  • 郑州网站建设亅汉狮网络百度网盘seo优化
  • 模板型网站seo优化平台
  • 官方网站下载免费软件培训机构有哪些?哪个比较好
  • 网站导航怎么做的惠州seo计费管理
  • 建设公司网站模板全国唯一一个没有疫情的城市
  • 网站怎么做seo_南京百度提升优化
  • 旅游网站开发与设计论文怎么样建网站
  • 北京网站推广排名公司企业网站的搜索引擎推广与优化
  • 动态网站期末设计广告营销策略
  • 山东网站营销推广费用旺道seo推广
  • 邢台网站建设服务周到百度数据分析工具
  • 周口网站建设竞价恶意点击犯法吗
  • 网站建设没有预付款seo快速提升排名
  • 网站开发者的设计构想网络推广平台软件
  • 做立体字的网站重庆seo公司排名
  • 电子商务网站的建设包含哪些流程搜索引擎关键词怎么优化
  • 将自己做的网站发布到谷歌推广新手教程
  • 深圳保障性住房管理办法seo排名优化方法
  • 2022注册公司取名推荐网络营销的优化和推广方式
  • 做网站费是多少贵州二级站seo整站优化排名
  • 做网站潍坊培训课程安排
  • python做网站需要什么seo学习论坛
  • 用手机怎样制作网站网络seo是什么
  • 企业网站开发信息搜索大全浏览器
  • 做虚拟货币交易网站域名注册平台有哪些
  • 企业网站首页的实现专业的网页制作公司
  • 动态网站建设教程宝鸡seo排名