本文整理汇总了PHP中Car::maxPassengers方法的典型用法代码示例。如果您正苦于以下问题:PHP Car::maxPassengers方法的具体用法?PHP Car::maxPassengers怎么用?PHP Car::maxPassengers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car::maxPassengers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Bike
<?php
include "Models/Bike.php";
include "Models/Car.php";
include "Models/Plane.php";
$minutos = 10;
$vehicle = new Bike();
echo $vehicle->getName() . ': </br>';
echo 'velocidad: ' . $vehicle->speed() . '</br>';
echo 'maximo de pasajeros: ' . $vehicle->maxPassengers() . '</br>';
echo 'distancia: ' . $vehicle->travelDistance($minutos) . '</br> </br>';
$vehicle2 = new Car();
echo $vehicle2->getName() . ': </br>';
echo 'velocidad: ' . $vehicle2->speed() . '</br>';
echo 'maximo de pasajeros: ' . $vehicle2->maxPassengers() . '</br>';
echo 'distancia: ' . $vehicle2->travelDistance($minutos) . '</br> </br>';
$vehicle3 = new Plane();
echo $vehicle3->getName() . ': </br>';
echo 'velocidad: ' . $vehicle3->speed() . '</br>';
echo 'maximo de pasajeros: ' . $vehicle3->maxPassengers() . '</br>';
echo 'distancia: ' . $vehicle3->travelDistance($minutos) . '</br> </br>';
示例2: switch
$var = $_POST['var'];
//$pas is now number of passengers load.
switch ($var) {
case '1':
$x = new Plane();
$max = $x->maxPassengers();
if ($new_pas <= $max) {
echo "You can travel now";
} else {
$name = $x->getName();
echo "You can not travel on a " . $name . " whit " . $new_pas . " passengers. The number of allowed passengers for the selected transport is " . $max;
}
break;
case '2':
$x = new Car();
$max = $x->maxPassengers();
if ($new_pas <= $max) {
echo "You can travel now";
} else {
$name = $x->getName();
echo "You can not travel on a " . $name . "whit" . $new_pas . "passengers. The number of alllowed passengers for the selected transport is" . $max;
}
break;
case '3':
$x = new Bike();
$max = $x->maxPassengers();
if ($new_pas <= $max) {
echo "You can travel now";
} else {
$name = $x->getName();
echo "You can not travel on a " . $name . "whit" . $new_pas . "passengers. The number of alllowed passengers for the selected transport is" . $max;