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

网站域名注册多少钱wordpress标签链接

网站域名注册多少钱,wordpress标签链接,mysql8.0 wordpress,网站维护具体工作内容访问者模式 介绍 设计模式定义案例问题堆积在哪里访问模式访问模式是行为型设计模式 从对象中分类出算法 这些算法封装为对象#xff0c; 这样这些算法类很容易扩展#xff0c;添加新的算法类就可以了不同的VIP用户 在不同的节日 领取不同的礼物if else太多 解决办法小技巧…访问者模式 介绍 设计模式定义案例问题堆积在哪里访问模式访问模式是行为型设计模式 从对象中分类出算法 这些算法封装为对象 这样这些算法类很容易扩展添加新的算法类就可以了不同的VIP用户 在不同的节日 领取不同的礼物if else太多 解决办法小技巧枚举出不同的用户类有一个相同的基类 枚举出不同的节日类有一个相同的基类 节日访问者 被 不同VIP等级用户访问 根据不同的用户给出不同的礼物  if else。。。转为重载函数方式 函数重载类型1 函数重载类型2 ... 传入不同的数据类型触发不同的重置函数 类图 代码 PlayerVipBase public abstract class PlayerVipBase {public string name; }PlayerVipSun  public class PlayerVipSun : PlayerVipBase {public PlayerVipSun(){name VipSun; } }PlayerVipMoon  public class PlayerVipMoon : PlayerVipBase {public PlayerVipMoon(){name VipMoon ; } }PlayerVipStar  public class PlayerVipStar : PlayerVipBase {public PlayerVipStar(){name VipStar;} } FestivalBase  interface FestivalBase {string GetGift(PlayerVipStar player);string GetGift(PlayerVipMoon player);string GetGift(PlayerVipSun player); }Festival_YuanXiaoJie  public class Festival_YuanXiaoJie : FestivalBase {public string GetGift(PlayerVipStar player){return player.name 领取了元宵节礼物: 66个复活币;}public string GetGift(PlayerVipMoon player){return player.name 领取了元宵节礼物: 可爱汤圆时装;}public string GetGift(PlayerVipSun player){return player.name 领取了元宵节礼物: SSR汤圆宝宝;} }Festival_GuoQingJie  public class Festival_GuoQingJie : FestivalBase {public string GetGift(PlayerVipStar player){return player.name 领取了国庆节礼物: 100R;}public string GetGift(PlayerVipMoon player){return player.name 领取了国庆节礼物: 2023国庆时装;}public string GetGift(PlayerVipSun player){return player.name 领取了国庆节礼物: SSR龙神;} } Festival_61  public class Festival_61 : FestivalBase {public string GetGift(PlayerVipStar player){return player.name 领取了儿童节礼物: 100QB;}public string GetGift(PlayerVipMoon player){return player.name 领取了儿童节礼物: 61时装;}public string GetGift(PlayerVipSun player){return player.name 领取了儿童节礼物: SSR凤凰宝宝;} } 测试代码 using UnityEngine;public class TestFWZ : MonoBehaviour {void Start(){// 不同Vip 等级的玩家PlayerVipStar player1 new PlayerVipStar();PlayerVipMoon player2 new PlayerVipMoon();PlayerVipSun player3 new PlayerVipSun();// 六一儿童节Festival_61 liuYi new Festival_61();// 国庆节Festival_GuoQingJie GuoQingJie new Festival_GuoQingJie();// 元宵节Festival_YuanXiaoJie YuanXiaoJie new Festival_YuanXiaoJie();// 领取奖励61儿童节Debug.Log(liuYi.GetGift(player1));Debug.Log(liuYi.GetGift(player2));Debug.Log(liuYi.GetGift(player3));Debug.Log(------------------------);// 领取奖励国庆Debug.Log(GuoQingJie.GetGift(player1));Debug.Log(GuoQingJie.GetGift(player2));Debug.Log(GuoQingJie.GetGift(player3));Debug.Log(------------------------);// 领取奖励国庆Debug.Log(YuanXiaoJie.GetGift(player1));Debug.Log(YuanXiaoJie.GetGift(player2));Debug.Log(YuanXiaoJie.GetGift(player3));} }结果 总结 访问者模式是拆分出了领奖行为 后封装为对象这个对象管理了礼物。 礼物管理员进一步拆分为 多个不同节日的礼物管理员 管理员可以自动识别玩家VIP等级 发送不同的礼物 这里小技巧“重载-获取礼物函数不同的玩家类型”
http://www.yutouwan.com/news/264944/

相关文章:

  • 做加工都在哪个网站推广企业展厅布置效果图大全
  • 长沙网站改版阿里关键词排名查询
  • div做网站网站做成微信小程序
  • 个人网站一年多少钱淘宝客网站建站源码
  • 如何快速找到公司网站卧龙区2015网站建设价格
  • 鄂州网站建设企业推广广告网站推荐
  • 高效的宝安网站推广做网站的算什么行业
  • 展馆设计网站推荐网络服务提供商有哪些
  • 建站宝盒后台网站开发技术难度
  • 竹木工艺品网站建设网页界面设计想法
  • 沈阳城市建设管理学校网站网站建设属于什么税目
  • 艺术网站欣赏网站开发排期表模板
  • 做网站用asp div代码网站开发需要解决的问题
  • 网站建设排名优化公司网站主题页
  • 老域名新网站推广企业融资需要准备哪些资料
  • 做设计找图有哪些网站有哪些做摄影网站的公司
  • 模块化网站开发电商运营教程
  • 做移动网站优化排名wordpress安装服务器
  • 有没有做家居服设计师看的网站如何注册网站名称
  • 如何用oss做视频网站广东建设信息网行业服务版
  • 河南网站开发优化百度分析工具
  • qq直接登录网站无需下载无锡网站制作联系电话
  • 建设工程敎育网网站星子网易云
  • 书籍网站开发多少钱档案馆建设网站
  • 网站制作合同范本网站做直播
  • 南宁做网站服务商做网站主页上主要放哪些内容
  • 江苏省品牌专业建设网站成都市小程序推广
  • 规划排版网站爱站长尾词
  • 网站建设岗位说明重庆seo网络推广平台
  • 十大免费自助建站做试试彩网站人员