五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(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ó)家法律
丹东市| 陇西县| 聊城市| 乌鲁木齐县| 东至县| 林州市| 本溪市| 黑龙江省| 南木林县| 微山县| 宜阳县| 任丘市| 金阳县| 玉林市| 通榆县| 海丰县| 喀喇| 花垣县| 盐津县| 聂荣县| 高淳县| 蓝山县| 拜城县| 瑞丽市| 兴化市| 建德市| 杭州市| 体育| 临泽县| 都匀市| 枣强县| 玉溪市| 平度市| 长子县| 文山县| 靖宇县| 北京市| 大竹县| 北辰区| 察雅县| 隆德县|