class Weather {
public function today()
{
//
return [
'temp' => rand(-50, 40),
'wind' => rand(10, 100)
];
}
}
class JapWea {
protected $wea;
public function __construct()
{
$this->wea = new Weather();
}
public function today()
{
$res = $this->wea->today();
$res['temp'] = $res['temp']*1.8+32;
$res['wind'] = floor($res['wind']/10);
return $res;
}
}
$japWea = new JapWea();
print_r($japWea->today());
php设计模式篇-适配器模式
最新推荐文章于 2025-12-10 19:19:59 发布

202

被折叠的 条评论
为什么被折叠?



