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

网站建设首选唯美谷网站开发中心

网站建设首选唯美谷,网站开发中心,阿里云网站怎么做,网站建设市场趋势Q.42 币圈生态链和行为模式 我认为#xff0c;上面和“币”有关的一系列概念和技术#xff0c;按设计模式的划分 #xff0c;整体应该都属于行为模式#xff0c;而且应该囊括行为模式的所有各个方面。 而行为又可以按照三种不同的导向#xff08;以目的或用途为导向、过…Q.42 币圈生态链和行为模式 我认为上面和“币”有关的一系列概念和技术按设计模式的划分 整体应该都属于行为模式而且应该囊括行为模式的所有各个方面。 而行为又可以按照三种不同的导向以目的或用途为导向、过程导向的和目标导向的来划分。这样就可以为 “币”设计三个抽象类作为顶层类别每一个都有相应的接口。 下面我们先抛开“币”不说单独说说设计模式“行为模式”本身该如何用程序来表示。等确定无误后我们再将它应用于“币”的及其相关概念上看看是否可以帮助解决前面提出的问题。 也就是说行为behavior作为一种设计模式可以设计 三个抽象类作为顶层类别代表了三种不同导向的行为类别。 在更深层层次上然后还可以为三个抽象类设计一个统一行为的元模型。这个元模型需要给出统一的行为准则该准则的超参将为应用行规(配置文件)profile中的tagged-value提供所有tag标记的标记值的地方即这个标记值是一个本体三元组该三元组作为建模超参用于训练模型 分别用作三种不同导向的行为的对象约束constraint 并且每一个超参都是一个用于模型评估的 匿名函数的占位符。所有占位符合起来表示了行为的构造型prototype。 同时标记名是一个伪码伪码可以使用由一个枚举类及有限的枚举文字enumeration.literal表示的集合元素 来表示。其中的每一个枚举文字都是 元层上的一个 命名空间 。 请根据以上内容给出统一行为behavior元模型以及相应的代码来翻译上述内容. 回答 以下是一个统一行为behavior元模型的示例代码 python from abc import ABC, abstractmethod# 三种不同导向的行为类别 class PurposeBehavior(ABC):abstractmethoddef execute(self):passclass ProcessBehavior(ABC):abstractmethoddef execute(self):passclass TargetBehavior(ABC):abstractmethoddef execute(self):pass# 统一行为的元模型 class UnifiedBehavior:def __init__(self, behavior):self.behavior behaviordef execute(self):self.behavior.execute()# 示例代码 class BuyBehavior(PurposeBehavior):def execute(self):print(Executing buy behavior)class SellBehavior(PurposeBehavior):def execute(self):print(Executing sell behavior)class MiningBehavior(ProcessBehavior):def execute(self):print(Executing mining behavior)class TradingBehavior(TargetBehavior):def execute(self):print(Executing trading behavior)# 使用统一行为的元模型 buy_behavior UnifiedBehavior(BuyBehavior()) buy_behavior.execute()sell_behavior UnifiedBehavior(SellBehavior()) sell_behavior.execute()mining_behavior UnifiedBehavior(MiningBehavior()) mining_behavior.execute()trading_behavior UnifiedBehavior(TradingBehavior()) trading_behavior.execute()这段代码示例了如何使用统一行为behavior元模型和三种不同导向的行为类别来定义和执行不同的行为。 Q43.在上面的程序中1) 没有将behavior和UML的profile的stereotypes、tagged-values和constraints关联上而在前面的描述中是有描述的2) 关于标记名的声明、标记值的处理相关的内容应该需要写出一个 配置文件profile的文本模板然后在程序中为处理模板中预设的插槽从而生成“行为”的应用程序。请完善补充代码。  以下是根据您的要求添加了与UML的profile关联以及配置文件profile的文本模板的代码补充 python from abc import ABC, abstractmethod# 三种不同导向的行为类别 class PurposeBehavior(ABC):abstractmethoddef execute(self):passclass ProcessBehavior(ABC):abstractmethoddef execute(self):passclass TargetBehavior(ABC):abstractmethoddef execute(self):pass# 统一行为的元模型 class UnifiedBehavior:def __init__(self, behavior):self.behavior behaviordef execute(self):self.behavior.execute()# 示例代码 class BuyBehavior(PurposeBehavior):def execute(self):print(Executing buy behavior)class SellBehavior(PurposeBehavior):def execute(self):print(Executing sell behavior)class MiningBehavior(ProcessBehavior):def execute(self):print(Executing mining behavior)class TradingBehavior(TargetBehavior):def execute(self):print(Executing trading behavior)# 配置文件profile的文本模板 profile_template ProfileBehaviorPurposeBehavior nameBuy /Behavior nameSell //PurposeProcessBehavior nameMining //ProcessTargetBehavior nameTrading //Target/Behavior /Profile # 解析配置文件profile class ProfileParser:staticmethoddef parse_profile(template):behaviors {}purpose_behaviors template.split(Purpose)[1].split(/Purpose)[0].split(Behavior name)[1:]for behavior in purpose_behaviors:behavior_name behavior.split()[1]behaviors[behavior_name] PurposeBehaviorprocess_behaviors template.split(Process)[1].split(/Process)[0].split(Behavior name)[1:]for behavior in process_behaviors:behavior_name behavior.split()[1]behaviors[behavior_name] ProcessBehaviortarget_behaviors template.split(Target)[1].split(/Target)[0].split(Behavior name)[1:]for behavior in target_behaviors:behavior_name behavior.split()[1]behaviors[behavior_name] TargetBehaviorreturn behaviors# 使用配置文件中定义的行为 profile_behaviors ProfileParser.parse_profile(profile_template) for behavior_name, behavior_class in profile_behaviors.items():unified_behavior UnifiedBehavior(behavior_class())print(fExecuting {behavior_name} behavior:)unified_behavior.execute()Q44. profile的程序和模板中都应该有stereotypes、tagged-values和constraints现在并全没有看到看看该怎样补齐程序  以下是添加了stereotypes、tagged-values和constraints的代码补充 python from abc import ABC, abstractmethod# 三种不同导向的行为类别 class PurposeBehavior(ABC):abstractmethoddef execute(self):passclass ProcessBehavior(ABC):abstractmethoddef execute(self):passclass TargetBehavior(ABC):abstractmethoddef execute(self):pass# 统一行为的元模型 class UnifiedBehavior:def __init__(self, behavior):self.behavior behaviordef execute(self):self.behavior.execute()# 示例代码 class BuyBehavior(PurposeBehavior):def execute(self):print(Executing buy behavior)class SellBehavior(PurposeBehavior):def execute(self):print(Executing sell behavior)class MiningBehavior(ProcessBehavior):def execute(self):print(Executing mining behavior)class TradingBehavior(TargetBehavior):def execute(self):print(Executing trading behavior)# 配置文件profile的文本模板 profile_template ProfileStereotypesStereotype namePurposeBehavior /Stereotype nameProcessBehavior /Stereotype nameTargetBehavior //StereotypesTaggedValuesTaggedValue nameauthor typestring /TaggedValue nameversion typeint //TaggedValuesConstraintsConstraint namevalidName //ConstraintsBehaviorPurposeBehavior nameBuy stereotypePurposeBehaviorTaggedValue nameauthor valueAlice /TaggedValue nameversion value1 //BehaviorBehavior nameSell stereotypePurposeBehaviorTaggedValue nameauthor valueBob /TaggedValue nameversion value2 //Behavior/PurposeProcessBehavior nameMining stereotypeProcessBehaviorTaggedValue nameauthor valueCharlie /TaggedValue nameversion value3 //Behavior/ProcessTargetBehavior nameTrading stereotypeTargetBehaviorTaggedValue nameauthor valueDavid /TaggedValue nameversion value4 //Behavior/Target/Behavior /Profile # 解析配置文件profile class ProfileParser:staticmethoddef parse_profile(template):behaviors {}purpose_behaviors template.split(Purpose)[1].split(/Purpose)[0].split(Behavior name)[1:]for behavior in purpose_behaviors:behavior_name behavior.split()[1]behaviors[behavior_name] PurposeBehaviorprocess_behaviors template.split(Process)[1].split(/Process)[0].split(Behavior name)[1:]for behavior in process_behaviors:behavior_name behavior.split()[1]behaviors[behavior_name] ProcessBehaviortarget_behaviors template.split(Target)[1].split(/Target)[0].split(Behavior name)[1:]for behavior in target_behaviors:behavior_name behavior.split()[1]behaviors[behavior_name] TargetBehaviorreturn behaviors# 使用配置文件中定义的行为 profile_behaviors ProfileParser.parse_profile(profile_template) for behavior_name, behavior_class in profile_behaviors.items():unified_behavior UnifiedBehavior(behavior_class())print(fExecuting {behavior_name} behavior:)unified_behavior.execute()在这段代码中我们添加了stereotypes、tagged-values和constraints的定义到配置文件profile的文本模板中。在解析配置文件时我们可以进一步扩展ProfileParser来处理这些额外的信息以便根据这些信息更具体地定义行为类别。
http://www.hkea.cn/news/14542959/

相关文章:

  • 公司网站制作要多少钱wordpress设置主页面
  • 模版建网站湛江师范学院网站开发技术
  • 工作一般做网站视频的工作叫做什么沧州市注册网络公司
  • 网站服务器问题优秀交互设计网站
  • 网站发布服务托管器开了个网站用年份做名字好吗
  • 江苏省建设厅 标准化网站跨国浏览器
  • 平顶山网站建设费用什么是跨境电商主要做什么
  • 怎么把自己做的网站中国货源网一件代发
  • 建站申请版面设计
  • 网站里做任务沈阳模板网站制作
  • 校园网站设计与实现长春网站开发培训
  • jquery插件网站推荐销售网站建设赚钱吗
  • 文字网站和图片网站哪个难做做安卓app用什么软件
  • 微网站的优缺点成都做小程序
  • 做网站需要那些技术自己买个服务器有什么用
  • 如何给网站做2维码长沙公积金网站怎么做异动
  • 哪个汽车网站汽贸店免费做兰州网站定制公司
  • 中国商标注册网官方网站北京响应式网站建设公司
  • 深圳方维网站设计公司wordpress 音乐播放插件
  • 响应式布局网站案例重庆seo俱乐部
  • 怎样查看网站点击量云主机租用服务
  • 个人网站可以做c2c吗网络营销方式主要有哪些
  • 做财务需要关注哪些网站wordpress网盘搜索引擎插件
  • 赣州南康网站建设wordpress 微商城模板
  • 个人做网站做什么样的话网站建设跟版网
  • 建站程序选择起飞页怎么做网站
  • 电脑广告设计软件seo管理与优化期末试题
  • 室内装修设计费收费标准seo优化推广多少钱
  • 设计的好网站wordpress 多说样式
  • 建设一个网站需要什么技术指标wordpress the7 汉化