phpにおける設計モード--フェースモード
1978 ワード
' ;
}
}
//(2) pc
class Pcmachine {
public function turnOn() {}
public function turnOff() {
echo 'turn off PcMathion
' ;
}
}
// (3)
class Power {
public function turnOn() {}
public function turnOff() {
echo 'turn off Power
' ;
}
}
//
class PcFacade implements Facade{
private $PcLight ;
private $Pcmachine ;
private $Power ;
public function __construct(){
$this->PcLight = new PcLight();
$this->Pcmachine = new Pcmachine();
$this->Power = new Power();
}
//
public function turnOff() {
$this->PcLight ->turnOff();
$this->Pcmachine ->turnOff();
$this->Power ->turnOff();
}
public function turnOn() {}
}
//
$button = new PcFacade();
$button ->turnOff();
/* ( . , , )