本文整理汇总了PHP中Car::fuelConsumption方法的典型用法代码示例。如果您正苦于以下问题:PHP Car::fuelConsumption方法的具体用法?PHP Car::fuelConsumption怎么用?PHP Car::fuelConsumption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car::fuelConsumption方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fuelConsumption
function fuelConsumption($distance)
{
$result = $this->fuel * $distance / 100;
return $result;
}
}
class Audi extends Car
{
}
$distance = 1000;
//
$car1 = new Car();
$car1->speed = 50;
$car1->fuel = 20;
echo "Время в пути " . $car1->rtipTime($distance) . "<br>";
echo "Расход топлива " . $car1->fuelConsumption($distance) . "<br>";
//
$car2 = new Car();
$car2->speed = 75;
$car2->fuel = 30;
echo "Время в пути " . $car2->rtipTime($distance) . "<br>";
echo "Расход топлива " . $car1->fuelConsumption($distance) . "<br>";
//
$bic = new Bicycle();
$bic->speed = 50;
echo "Время в пути " . $bic->rtipTime($distance) . "<br>";
echo "Расход калорий " . $bic->caloriesBurned($distance) . "<br>";
?>
</body>
</html>
示例2: Car
}
}
$car1 = new Car();
$car1->speed = 110;
$car1->fuel = 12;
$car2 = new Car();
$car2->speed = 130;
$car2->fuel = 14;
$bycicle = new Bycicle();
$bycicle->speed = 20;
$distance = 300;
echo '<br> Car1 time: ' . $car1->tripTime($distance);
echo '<br> Car2 time: ' . $car2->tripTime($distance);
echo '<br> Bycicle time: ' . $bycicle->tripTime($distance);
echo '<br>Количество топлива для CAR1 равняется: ' . $car1->fuelConsumption($distance);
echo '<br>Количество топлива для CAR2 равняется: ' . $car2->fuelConsumption($distance);
echo '<br>Количество калорий потраченных объектом равняется: ' . $bycicle->caloriesBurned($distance);
//$car = new Car();
//$car->speed = 170;
//echo $car->tripTime(1000);
//echo 'Расход топлива на 100 км: ' . $car->fuel . ' литров';
//echo '<br>';
//$km = 480;
//
//echo "На $km километров понадобится " . $car->fuelConsumption($km) . " литров топлива";
//echo '<hr>';
//
//
//$velik = new Bycicle;
//$velik->type = 'Детский';
//echo $velik->type;