国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

12-抽象工廠方法模式(Easy搞定Golang設(shè)計(jì)模式)

2023-06-18 22:37 作者:吃饅頭啊啊啊  | 我要投稿

package main


import "fmt"


type CPU interface {

Calculate()

}


type GPU interface {

Display()

}


type Memory interface {

Storage()

}


type VendorFactory interface {

VendorCPU()

VendorGPU()

VendorMemory()

}


type IntelCPU struct {

}


func (ic *IntelCPU) Calculate() {

fmt.Println("Intel Cpu Calculating...")

}


type IntelGPU struct {

}


func (ig *IntelGPU) Display() {

fmt.Println("Intel Gpu Displaying...")

}


type IntelMemory struct {

}


func (im *IntelMemory) Storage() {

fmt.Println("Intel Memory Storage...")

}


type IntelFactory struct {

}


func (ifac *IntelFactory) VendorCPU() CPU {

return &IntelCPU{}

}


func (ifac *IntelFactory) VendorGPU() GPU {

return &IntelGPU{}

}


func (ifac *IntelFactory) VendorMemory() Memory {

return &IntelMemory{}

}


type NvidiaCPU struct {

}


func (nc *NvidiaCPU) Calculate() {

fmt.Println("Nvidia Cpu Calculating...")

}


type NvidiaGPU struct {

}


func (nv *NvidiaGPU) Display() {

fmt.Println("Nvidia Gpu Displaying...")

}


type NvidiaMemory struct {

}


func (im *NvidiaMemory) Storage() {

fmt.Println("Nvidia Memory Storage...")

}


type NvidiaFactory struct {

}


func (ifac *NvidiaFactory) VendorCPU() CPU {

return &NvidiaCPU{}

}


func (ifac *NvidiaFactory) VendorGPU() GPU {

return &NvidiaGPU{}

}


func (ifac *NvidiaFactory) VendorMemory() Memory {

return &NvidiaMemory{}

}


type KingstonCPU struct {

}


func (ic *KingstonCPU) Calculate() {

fmt.Println("Kingston Cpu Calculating...")

}


type KingstonGPU struct {

}


func (ig *KingstonGPU) Display() {

fmt.Println("Kingston Gpu Displaying...")

}


type KingstonMemory struct {

}


func (im *KingstonMemory) Storage() {

fmt.Println("Kingston Memory Storage...")

}


type KingstonFactory struct {

}


func (ifac *KingstonFactory) VendorCPU() CPU {

return &IntelCPU{}

}


func (ifac *KingstonFactory) VendorGPU() GPU {

return &IntelGPU{}

}


func (ifac *KingstonFactory) VendorMemory() Memory {

return &IntelMemory{}

}


func main() {


intel := IntelFactory{}

nvidia := NvidiaFactory{}

kingston := KingstonFactory{}


fmt.Println("Install first pc:")

intel.VendorCPU().Calculate()

intel.VendorGPU().Display()

intel.VendorMemory().Storage()


fmt.Println("Install second pc:")

intel.VendorCPU().Calculate()

nvidia.VendorGPU().Display()

kingston.VendorMemory().Storage()

}

12-抽象工廠方法模式(Easy搞定Golang設(shè)計(jì)模式)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
中宁县| 沂源县| 永定县| 横峰县| 黄大仙区| 托克托县| 盈江县| 永德县| 子洲县| 台中市| 中宁县| 舞阳县| 镶黄旗| 富顺县| 石门县| 彭州市| 重庆市| 陆河县| 建宁县| 团风县| 南乐县| 海门市| 莲花县| 板桥市| 都江堰市| 寻乌县| 仙桃市| 绥滨县| 漳平市| 南陵县| 邵武市| 兴化市| 桐乡市| 岢岚县| 射洪县| 汾西县| 荥阳市| 汉阴县| 绍兴县| 靖州| 黄梅县|