五月天青色头像情侣网名,国产亚洲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ó)家法律
南宫市| 荥经县| 曲阜市| 合川市| 南木林县| 奈曼旗| 舟山市| 禹城市| 乌审旗| 靖西县| 炉霍县| 磐安县| 象州县| 潢川县| 九江市| 临桂县| 扬中市| 上犹县| 宁阳县| 高淳县| 霍山县| 许昌市| 肃宁县| 崇左市| 逊克县| 星子县| 赤壁市| 方山县| 罗甸县| 都昌县| 兰溪市| 霍林郭勒市| 沙坪坝区| 策勒县| 莱州市| 仪征市| 沽源县| 济源市| 镇远县| 巴里| 东阿县|