<?php header('Content-Type:text/html;charset=utf-8'); /* * 装饰模式【衣服搭配】 * Author: Kaysen */ define('ROOT_PATH', dirname(__FILE__)); require_once ROOT_PATH . '/../../Loader.php'; $xiaocai = new Person('小菜'); echo '第一种装扮<br>'; $pqx = new Sneakers(); $kk = new Bigtrouser(); $dtx = new Tshirts(); $pqx->decorate($xiaocai); $kk->decorate($pqx); $dtx->decorate($kk); $dtx->show();
<?php require_once 'Shoes.php'; require_once 'Sneakers.php'; require_once 'Shoelace.php'; $shoelace = new Shoelace(100, 'white'); $sneaker = new Sneakers(42, 'white', $shoelace); $sneaker->run(); $sneaker->printSpeed();