pkg

package
v0.0.0-...-8d22ec3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Computer

type Computer struct {
	// contains filtered or unexported fields
}

func (*Computer) GetColor

func (s *Computer) GetColor() string

func (*Computer) GetSize

func (s *Computer) GetSize() int

func (*Computer) SetColor

func (s *Computer) SetColor(color string)

func (*Computer) SetSize

func (s *Computer) SetSize(size int)

type InterfaceComputer

type InterfaceComputer interface {
	SetColor(color string)
	SetSize(size int)
	GetColor() string
	GetSize() int
}

定义电脑接口

type InterfaceElectronicFactory

type InterfaceElectronicFactory interface {
	MakePhone() InterfacePhone
	MakeComputer() InterfaceComputer
}

电子产品工厂

func GetElectronicFactory

func GetElectronicFactory(brand string) (InterfaceElectronicFactory, error)

获取电子产品工厂

type InterfacePhone

type InterfacePhone interface {
	SetColor(color string)
	SetSize(size int)
	GetColor() string
	GetSize() int
}

定义手机接口

type Lenovo

type Lenovo struct {
}

联想品牌工厂

func (*Lenovo) MakeComputer

func (n *Lenovo) MakeComputer() InterfaceComputer

生产电脑

func (*Lenovo) MakePhone

func (n *Lenovo) MakePhone() InterfacePhone

生产手机

type LenovoComputer

type LenovoComputer struct {
	Computer
}

联想电脑

type LenovoPhone

type LenovoPhone struct {
	Phone
}

联想手机

type Phone

type Phone struct {
	// contains filtered or unexported fields
}

func (*Phone) GetColor

func (s *Phone) GetColor() string

func (*Phone) GetSize

func (s *Phone) GetSize() int

func (*Phone) SetColor

func (s *Phone) SetColor(color string)

func (*Phone) SetSize

func (s *Phone) SetSize(size int)

type Xiaomi

type Xiaomi struct {
}

小米品牌工厂

func (*Xiaomi) MakeComputer

func (a *Xiaomi) MakeComputer() InterfaceComputer

生产电脑

func (*Xiaomi) MakePhone

func (a *Xiaomi) MakePhone() InterfacePhone

生产手机

type XiaomiComputer

type XiaomiComputer struct {
	Computer
}

小米电脑

type XiaomiPhone

type XiaomiPhone struct {
	Phone
}

小米手机

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL