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

个人网站免费空间申请如何提高网站搜索排名

个人网站免费空间申请,如何提高网站搜索排名,制作一个独立网站多少钱,专业3合1网站建设电话文章目录 1. 概述1.1 角色1.2 类图 2. 代码示例2.1 设计2.2 代码2.3 类图 1. 概述 1.1 角色 AbstractFactory(抽象工厂):它声明了一组用于创建产品的方法,每一个方法对应一种产品。ConcreteFactory(具体工厂&#xf…

文章目录

  • 1. 概述
    • 1.1 角色
    • 1.2 类图
  • 2. 代码示例
    • 2.1 设计
    • 2.2 代码
    • 2.3 类图

1. 概述

1.1 角色

  • AbstractFactory(抽象工厂):它声明了一组用于创建产品的方法,每一个方法对应一种产品。
  • ConcreteFactory(具体工厂):它实现了在抽象工厂中声明的创建产品的方法,生成一组具体产品,这些产品构成了一个产品族,每一个产品都位于某个产品等级结构中。
  • AbstractProduct(抽象产品):它为每种产品声明接口,在抽象产品中声明了产品所具有的业务方法。
  • ConcreteProduct(具体产品):它定义具体工厂生产的具体产品对象,实现抽象产品接口中声明的业务方法。

1.2 类图

«interface»
ProductA
ProductA1
ProductA2
«interface»
ProductB
ProductB1
ProductB2
Client
«interface»
AbstractFactory
+CreateProductA() : ProductA
+CreateProductB() : ProductB
ConcreteFactory1
+CreateProductA() : ProductA
+CreateProductB() : ProductB
ConcreteFactory2
+CreateProductA() : ProductA
+CreateProductB() : ProductB

2. 代码示例

2.1 设计

  • 定义抽象产品A
    • 定义具体产品A-1
      • 它有NameWeight两个成员
      • 它的SetName()SetWeight()两个方法分别负责设置以上两个成员
      • 它的Get()方法获取它本身的信息
    • 定义具体产品A-2
      • 它有NameWeight两个成员
      • 它的SetName()SetWeight()两个方法分别负责设置以上两个成员
      • 它的Get()方法获取它本身的信息
  • 定义抽象产品B
    • 定义具体产品B-1
      • 它有NameHeight两个成员
      • 它的SetName()SetHeight()两个方法分别负责设置以上两个成员
      • 它的Get()方法获取它本身的信息
    • 定义具体产品B-2
      • 它有NameHeight两个成员
      • 它的SetName()SetHeight()两个方法分别负责设置以上两个成员
      • 它的Get()方法获取它本身的信息
  • 定义抽象工厂
    • 定义具体工厂1
      • 它的方法SetProductA()设置具体产品A-1
      • 它的方法SetProductB()设置具体产品B-1
    • 定义具体工厂2
      • 它的方法SetProductA()设置具体产品A-2
      • 它的方法SetProductB()设置具体产品B-2
  • 定义一个函数CreateFactory(),用来创建具体工厂
  • 调用
    • CreateFactory()函数实例化 具体工厂1——factory1
    • factory1实例化产品A-1产品B-1,并查看结果
    • CreateFactory()函数实例化 具体工厂2——factory2
    • factory2实例化产品A-2产品B-2,并查看结果

2.2 代码

package mainimport "fmt"// 定义抽象产品A
type AbstractProductA interface {SetName(name string)SetWeight(weight int64)Get()
}// 定义具体产品A-1
type ConcreteProductA1 struct {Name   stringWeight int64
}func (c *ConcreteProductA1) SetName(name string) {c.Name = name
}func (c *ConcreteProductA1) SetWeight(weight int64) {c.Weight = weight
}func (c *ConcreteProductA1) Get() {fmt.Printf("%v\n", c)
}// 定义具体产品A-2
type ConcreteProductA2 struct {Name   stringWeight int64
}func (c *ConcreteProductA2) SetName(name string) {c.Name = name
}func (c *ConcreteProductA2) SetWeight(weight int64) {c.Weight = weight
}
func (c *ConcreteProductA2) Get() {fmt.Printf("%v\n", c)
}// 定义抽象产品B
type AbstractProductB interface {SetName(name string)SetHeight(height int64)Get()
}// 定义具体抽象产品B-1
type ConcreteProductB1 struct {Name   stringHeight int64
}func (c *ConcreteProductB1) SetName(name string) {c.Name = name
}func (c *ConcreteProductB1) SetHeight(height int64) {c.Height = height
}
func (c *ConcreteProductB1) Get() {fmt.Printf("%v\n", c)
}// 定义具体产品B-2
type ConcreteProductB2 struct {Name   stringHeight int64
}func (c *ConcreteProductB2) SetName(name string) {c.Name = name
}func (c *ConcreteProductB2) SetHeight(height int64) {c.Height = height
}
func (c *ConcreteProductB2) Get() {fmt.Printf("%v\n", c)
}// Factory部分// 定义抽象工厂
type Factory interface {SetProductA(name string, weight int64) AbstractProductASetProductB(name string, height int64) AbstractProductB
}// 定义具体工厂1
type Factory1 struct {
}func (f *Factory1) SetProductA(name string, weight int64) AbstractProductA {a := &ConcreteProductA1{}a.SetName(name)a.SetWeight(weight)return a
}func (f *Factory1) SetProductB(name string, height int64) AbstractProductB {a := &ConcreteProductB1{}a.SetName(name)a.SetHeight(height)return a
}// 定义具体工厂2
type Factory2 struct {
}func (f *Factory2) SetProductA(name string, weight int64) AbstractProductA {a := &ConcreteProductA2{}a.SetName(name)a.SetWeight(weight)return a
}func (f *Factory2) SetProductB(name string, height int64) AbstractProductB {a := &ConcreteProductB2{}a.SetName(name)a.SetHeight(height)return a
}// 写一个创建工厂的函数
func CreateFactory(pType int64) Factory {switch pType {case 1:return &Factory1{}case 2:return &Factory2{}}return nil
}func main() {factory1 := CreateFactory(1)factory1.SetProductA("A1", 3).Get()factory1.SetProductB("B1", 3).Get()factory2 := CreateFactory(2)factory2.SetProductA("A2", 4).Get()factory2.SetProductB("B2", 4).Get()
}
  • 输出
&{A1 3}
&{B1 3}
&{A2 4}
&{B2 4}

2.3 类图

«interface»
ProductA
+SetName(name string)
+SetWeight(weight int64)
+Get()
ProductA1
-Name string
-Weight int64
+SetName(name string)
+SetWeight(weight int64)
+Get()
ProductA2
-String Name
-Int64 Weight
+SetName(name string)
+SetWeight(weight int64)
+Get()
«interface»
ProductB
+SetName(name string)
+SetHeight(height int64)
+Get()
ProductB1
-String Name
-Int64 Height
+SetName(name string)
+SetHeight(height int64)
+Get()
ProductB2
-String Name
-Int64 Height
+SetName(name string)
+SetHeight(height int64)
+Get()
Client
«interface»
AbstractFactory
+SetProductA(name string, weight int64) : AbstractProductA
+SetProductB(name string, height int64) : AbstractProductB
ConcreteFactory1
+SetProductA(name string, weight int64) : AbstractProductA
+SetProductB(name string, height int64) : AbstractProductB
ConcreteFactory2
+SetProductA(name string, weight int64) : AbstractProductA
+SetProductB(name string, height int64) : AbstractProductB

在这里插入图片描述

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

相关文章:

  • 做的好的营销型网站有哪些内容外贸网站外链平台
  • 东营网站建设预算价格百度网盘网页版入口官网
  • 网站建设中标公告18款禁用看奶app入口
  • 网站运营人员岗位职责长沙正规seo优化价格
  • cnzz统计代码放在后台网站为什么没显示seo的英文全称是什么
  • 杭州企业网站建设方案广告门
  • 自己免费做网站(二)seo优化公司信
  • 广州外贸b2b网站建设刷钻业务推广网站
  • 做企业网站用什么怎样宣传自己的品牌
  • 濮阳做网站的公司我的百度账号
  • 美食网站开发如何做好网络营销工作
  • 网站建设案例资料今天的新闻内容
  • 台州专业网站建设方案seo软文代写
  • 个人网站 百度推广全球搜索大全
  • 网站消息推送5118素材网站
  • 天津 响应式网站设计企业网站模板免费
  • 网站用花生壳nas做存储百度seo发包工具
  • wordpress cache深圳纯手工seo
  • 怎样找到正规代加工网站百度地图3d实景地图
  • 潍坊网站建设公司网站搭建免费
  • 惠州做网站好的公司下载百度语音导航地图安装
  • 春节网站怎么做小说排行榜百度搜索风云榜
  • 商城服务是什么软件seo是指什么岗位
  • 无锡网站建设有限公司网站快速收录的方法
  • 网站建设通报推广网站多少钱
  • 网络推广公司成都seo排名优化教程
  • 一台手机登录微信网页版西安优化外
  • 如何做旅游攻略网站长沙seo优化推荐
  • 长春火车站电话咨询电话快排seo
  • 龙城建设网站公司网站内容优化方法