当前位置: 首页>>代码示例>>PHP>>正文


PHP Car::fuelConsumption方法代码示例

本文整理汇总了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>
开发者ID:naelrouz,项目名称:phpStartVZ0,代码行数:30,代码来源:14.php

示例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;
开发者ID:EvgeniUPS,项目名称:project,代码行数:31,代码来源:vehicle.php


注:本文中的Car::fuelConsumption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。