Пример #1
0
 public function __construct($rank, $suit = null)
 {
     if ($suit == null) {
         $suit = Suit::getRandomSuit();
     }
     $this->suit = $suit;
     $this->rank = $rank;
 }
Пример #2
0
 /**
  * @param string $card
  * @return Card
  */
 public static function fromString($card)
 {
     list($rank, $suit) = str_split($card);
     return new Card(Rank::fromString($rank), Suit::fromString($suit));
 }
Пример #3
0
 /**
  * Get the suit name the card
  *
  * @return string 
  */
 public function suitName()
 {
     return $this->suit->name();
 }
Пример #4
0
    public function show()
    {
        echo "皮鞋 ";
        parent::show();
    }
}
//客户端代码
$xc = new Person();
$xc->setName('小菜');
var_dump('第一种装装扮');
$dtx = new Tshirt();
//大T恤
$kk = new BigTrouser();
//跨裤
$pqx = new Sneaker();
//破球鞋
$dtx->decorator($xc);
$kk->decorator($dtx);
$pqx->decorator($kk);
$pqx->show();
var_dump("第二中装饰");
$ld = new tie();
//领带
$xz = new Suit();
//西装
$px = new leatherShoe();
//皮鞋
$ld->decorator($xc);
$xz->decorator($ld);
$px->decorator($xz);
$px->show();