"I''m reading now......<br>";
}
function Wdata(){
echo "I''m writing now......<hr>";
}
}
class Adpater implements readandwrite{
private $obj;
function __construct(unknow $x){
$this->obj=$x;
}
function read(){
$this->obj->Rdata();
}
function write(){
$this->obj->Wdata();
}
}
//【
程序主体调用】
echo "<strong><font color=#990000 size=20px>面向对象
程序设计——接口</font></strong><hr>";
$storage1=new flash();
$computer=new motherboard($storage1);
$computer->read();
$computer->write();
$storage2=new yingpan();
$computer=new motherboard($storage2);
$computer->read();
$computer->write();
$storage3=new disco();
$computer=new motherboard($storage3);
$computer->read();
$computer->write();
$un_storage=new unknow();
$apdaterx=new Adpater($un_storage);
$computer=new motherboard($apdaterx);
$computer->read();
$computer->write();
?>