forked from go/golangs_learn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
559 B
40 lines
559 B
4 years ago
|
package facade
|
||
|
|
||
|
import "fmt"
|
||
|
|
||
|
type CarModel struct {
|
||
|
}
|
||
|
|
||
|
func NewCarModel() *CarModel {
|
||
|
return &CarModel{}
|
||
|
}
|
||
|
func (c *CarModel) SetModel() {
|
||
|
fmt.Println("SetModel测试...", c)
|
||
|
}
|
||
|
|
||
|
type CarEngine struct {
|
||
|
}
|
||
|
|
||
|
func (c *CarEngine) SetEngine() {
|
||
|
fmt.Println("SetEngine测试...", c)
|
||
|
}
|
||
|
|
||
|
type CarBody struct {
|
||
|
}
|
||
|
|
||
|
func (c *CarBody) SetBody() {
|
||
|
fmt.Println("SetBody测试...", c)
|
||
|
}
|
||
|
|
||
|
type CarFacade struct {
|
||
|
model CarModel
|
||
|
engine CarEngine
|
||
|
body CarBody
|
||
|
}
|
||
|
|
||
|
func (c *CarFacade) CreateCompleteCar() {
|
||
|
c.model.SetModel()
|
||
|
c.engine.SetEngine()
|
||
|
c.body.SetBody()
|
||
|
}
|