<?php
abstract class Traffic{
abstract public function move($foot);
public function color($col){
echo "The traffic is ".$col."\n";
}
}
class car extends Traffic{
public function move($foot){
echo "the car moves ".$foot." m."."\n";
}
}
class train extends Traffic{
public function move($foot){
echo "the train moves ".$foot." m."."\n";
}
}
$cars = new car();
$trains = new train();
$cars->move("20");
$cars->color("red");
$trains->move("50");
$trains->color("green");
?>
PHP面对对象抽象类练习
最新推荐文章于 2024-08-17 22:56:29 发布