<?php
// 人类
class Person
{
private
$name;
public function __construct($name)
{
$this->name =
$name;
}
public function
Show()
{
echo
"装扮" . $this->name;
}
}
//服饰类
class Finery
extends Person
{
protected
component;
public function Decoration(Person
$component)
{
$this->component = $component;
}
public function Show()
{
if($this->component !=
null)
{
$this->component->Show();
}
}
}
// 具体服饰类
class TShirts extends
Finery
{
public function Show()
{
echo "T 恤";
$this->Show();
}
}
class BigTrouser extends Finery
{
public function Show()
{
echo "大裤";
$this->Show();
}
}
class Suit extends
Finery
{
public function Show()
{
echo "西装";
$this->Show();
}
}
$p = new Person("狗娘养的");
$bt = new
BigTrouser();
$bt.Decoration($p);
$bt.Show();