<?php
interface Love
{
function shajiao();
}
class Lovely implements Love
{
function shajiao()
{
echo "ke ai xing shajiao <br />";
// TODO: Implement shajiao() method.
}
}
class Tiger implements Love
{
function shajiao()
{
// TODO: Implement shajiao() method.
echo "tiger xing sha jiao";
}
}
class GirlFriend
{
protected $xingge;
function __construct ($xingge)
{
$this->xingge = $xingge;
}
function shajiao ()
{
$this->xingge->shajiao();
}
}
$lovely = new Lovely();
$li = new GirlFriend($lovely);
$li->shajiao();
php高级实战-策略模式
最新推荐文章于 2024-08-22 09:44:18 发布