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.
 
 
 
 
 
 

653 B

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()
}
  • 外观模式

  • 将整体封装起来,对外仅仅展示一个 调用接口