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

找建筑师设计房子seo网站优化建议

找建筑师设计房子,seo网站优化建议,东莞房价走势图,做网站一般几个人文章目录 前言代码结果总结 前言 本文章尝试使用go实现“原型”。 代码 package mainimport ("fmt" )// 不同原型标志枚举 type Type intconst (PROTOTYPE_1 Type iotaPROTOTYPE_2 )// 原型接口 type IPrototype interface {Clone() IPrototypeMethod(value int)P…

文章目录

  • 前言
  • 代码
  • 结果
  • 总结


前言

本文章尝试使用go实现“原型”。


代码

package mainimport ("fmt"
)// 不同原型标志枚举
type Type intconst (PROTOTYPE_1 Type = iotaPROTOTYPE_2
)// 原型接口
type IPrototype interface {Clone() IPrototypeMethod(value int)Print()
}// 具体原型1
type ConcretePrototype1 struct {name  stringvalue int
}// 构造函数
func NewConcretePrototype1ByFields(name string, value int) *ConcretePrototype1 {return &ConcretePrototype1{name,value,}
}func NewConcretePrototype1ByObject(cp *ConcretePrototype1) *ConcretePrototype1 {return &ConcretePrototype1{name:  cp.name,value: cp.value,}
}// 接口方法
func (cp *ConcretePrototype1) Clone() IPrototype {return NewConcretePrototype1ByObject(cp)
}func (cp *ConcretePrototype1) Method(value int) {cp.value = value
}func (cp *ConcretePrototype1) Print() {fmt.Println("Call Method1 from ", cp.name, " with field : ", cp.value)
}// 具体原型2
type ConcretePrototype2 struct {name  stringvalue int
}// 构造函数
func NewConcretePrototype2ByFields(name string, value int) *ConcretePrototype2 {return &ConcretePrototype2{name,value,}
}func NewConcretePrototype2ByObject(cp *ConcretePrototype2) *ConcretePrototype2 {return &ConcretePrototype2{name:  cp.name,value: cp.value,}
}// 接口方法
func (cp *ConcretePrototype2) Clone() IPrototype {return NewConcretePrototype2ByObject(cp)
}func (cp *ConcretePrototype2) Method(value int) {cp.value = value
}func (cp *ConcretePrototype2) Print() {fmt.Println("Call Method2 from ", cp.name, " with field : ", cp.value)
}// 原型工厂
type PrototypeFactory struct {prototypes map[Type]IPrototype
}func NewPrototypeFactory() *PrototypeFactory {return &PrototypeFactory{prototypes: map[Type]IPrototype{PROTOTYPE_1: NewConcretePrototype1ByFields("PROTOTYPE_1 ", 1),PROTOTYPE_2: NewConcretePrototype2ByFields("PROTOTYPE_2 ", 2),},}
}func (p *PrototypeFactory) CreatePrototype(t Type) IPrototype {return p.prototypes[t].Clone()
}// 客户端代码
func clientCode(p *PrototypeFactory) {fmt.Println("Let's create a Prototype 1")prototype1 := p.CreatePrototype(PROTOTYPE_1)prototype2 := p.CreatePrototype(PROTOTYPE_1)prototype1.Method(3)prototype2.Method(4)prototype1.Print()prototype2.Print()fmt.Println()fmt.Println("Let's create a Prototype 2")prototype1 = p.CreatePrototype(PROTOTYPE_2)prototype2 = p.CreatePrototype(PROTOTYPE_2)prototype1.Method(5)prototype2.Method(6)prototype1.Print()prototype2.Print()
}func main() {clientCode(NewPrototypeFactory())
}

结果

Let's create a Prototype 1
Call Method1 from  PROTOTYPE_1   with field :  3
Call Method1 from  PROTOTYPE_1   with field :  4Let's create a Prototype 2
Call Method2 from  PROTOTYPE_2   with field :  5
Call Method2 from  PROTOTYPE_2   with field :  6

总结

新人设计模式理解,望大家多多指点。

http://www.wangmingla.cn/news/53358.html

相关文章:

  • 租个国内服务器做网站多少钱百度竞价推广登陆
  • 做网站的网页图片素材怎么找nba最新交易汇总
  • 青岛迅优网站建设百度账号管理
  • 昆山做网站哪家好网站关键词排名怎么提升
  • 国外最牛设计网站百度关键词工具
  • 网站建设功能说明书竞价推广外包托管
  • 无锡室内设计学校石家庄手机端seo
  • 单页面网站制作教程百度推广服务
  • 宁波做公司网站的公司推广网站的四种方法
  • 网站开发小公司推荐网络营销研究背景及意义
  • 做网站软件定制开发关键词推广技巧
  • 西安企业网站建设哪家好建站
  • 怎样写网站设计意义怎么投放广告
  • 广州做网络服装的网站建设广州网站优化推广方案
  • 怎么设计一个网站seo需要培训才能找到工作吗
  • 亚洲永久精品ww47香蕉图片北京seo网站开发
  • 个人直播网站开发磁力狗bt
  • 企业做网站的发票会计分录站长工具服务器查询
  • 做精神科网站价格推广链接点击器
  • 建设网站的技术手段关键词排名点击软件怎样
  • 环保类网站模板免费下载站长之家域名信息查询
  • 昆明网络推广方式有哪些seo自学
  • web网站开发公司爱站工具包下载
  • 温州做网站哪里好益阳网站seo
  • 嵌入式开发工程师合肥seo排名优化
  • 西安哪里做网站最大成人培训班有哪些课程
  • wordpress文章某个时间段可查看甘肃seo网站
  • 济南好的网站建设公司哪家好代发软文
  • 单位网站建设申请西安优化排名推广
  • wordpress搭建的网站网络推广方案怎么写