门面模式又叫外观模式,用来隐藏系统的复杂性,并向客户端提供了一酸奶可以加热吗个客户端可以访问系统的接口。这种类型的设计先生的英文缩写模式属于结构型模式,它向现有的系统添加一个接口,来隐藏系统的复杂性。
这种模式涉及到一个单一的类,该类提供了客户端请求的简化方法和对现有系统类方法的委托调用。
<?phpinterface shape{ public function draw();}class circle implements shape{ public function draw(){ echo "画一个圆形\n"; }}class rectangle implements shape{ public function draw(){ echo "画一个矩形\n"; }}class square implements shape{ public function draw(){ echo "画一个正方形\n"; }}class sh邻居阿姨apemark{ public $circle; public $rectangle; public $squar珠海 大学e; public function __construct(){ $this->circle = new circle(); $this->rectangle = new rectangle(); $this->square = new square(); } public function drawcircle(){ $this->circle->draw(); } public function drawrectangle(){ 关于新闻的作文 $this->rectangle->draw(); } public function drawsquare(){ $this->square->draw(); }}$shapemark = new shapemark();$shapemark->drawcircle();//画一个圆形$shapemark->drawrectangle();//画一个矩形$shapemark->drawsquare();//画一个正方形
本文发布于:2023-04-07 05:07:18,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/25dde420b669b6a33da8b1fe503423f6.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:【php设计模式】门面模式.doc
本文 PDF 下载地址:【php设计模式】门面模式.pdf
留言与评论(共有 0 条评论) |