<?php
// 子系统A
class SubSystemA
{
public function operationA()
{
echo “SubSystemA operation.\n”;
}
}
// 子系统B
class SubSystemB
{
public function operationB()
{
echo “SubSystemB operation.\n”;
}
}
// 子系统C
class SubSystemC
{
public function operationC()
{
echo “SubSystemC operation.\n”;
}
}
// 外观类
class Facade
{
private $subSystemA;
private $subSystemB;
private $subSystemC;
public function __construct()
{
$this->subSystemA=new SubSystemA();
$this->subSystemB=new SubSystemB();
$this->subSystemC=new SubSystemC();
}
public function operation()
{
$this->subSystemA->operationA();
$this->subSystemB->operationB();
$this->subSystemC->operationC();
}
}
// 客户端代码
$facade=new Facade();
$facade->operation();
// 子系统A
class SubSystemA
{
public function operationA()
{
echo “SubSystemA operation.\n”;
}
}
// 子系统B
class SubSystemB
{
public function operationB()
{
echo “SubSystemB operation.\n”;
}
}
// 子系统C
class SubSystemC
{
public function operationC()
{
echo “SubSystemC operation.\n”;
}
}
// 外观类
class Facade
{
private $subSystemA;
private $subSystemB;
private $subSystemC;
public function __construct()
{
$this->subSystemA=new SubSystemA();
$this->subSystemB=new SubSystemB();
$this->subSystemC=new SubSystemC();
}
public function operation()
{
$this->subSystemA->operationA();
$this->subSystemB->operationB();
$this->subSystemC->operationC();
}
}
// 客户端代码
$facade=new Facade();
$facade->operation();
© 版权声明
文章版权归作者所有,未经允许请勿转载。