标签:blog http io ar div on log cti bs
<?php /*桥接模式:将抽象部分与实现部分分离,使它们都可以独立的变化。 * * 在软件系统中,某些类型由于自身的逻辑,它具有两个或多个维度的变化,桥接模式就是应对这种多维度的变化 */ /*例子:不同的车在不同的街道上行驶。车可变,街道可变 * * */ abstract class road{ abstract public function run(); } class quickroad extends road{ public $car; public function __construct($car){ $this->car = $car; } public function run(){ $this->car->run(); echo ‘高速公路上行驶‘; } } class street extends road{ public $car; public function __construct($car){ $this->car = $car; } public function run(){ $this->car->run(); echo ‘城市街道上行驶‘; } } abstract class car{ abstract public function run(); } class jeep extends car{ public function run(){ echo ‘吉普车在‘; } } class bus extends car{ public function run(){ echo ‘公共汽车在‘; } } $car = new bus(); $road = new quickroad($car); $road->run(); echo "<br/>"; $car = new jeep(); $road = new street($car); $road->run(); ?>
UML类图
标签:blog http io ar div on log cti bs
原文地址:http://www.cnblogs.com/taijun/p/4075736.html