Пример #1
0
echo $car1->brand;
echo "<br>";
echo $car1->speed;
echo "<br>";
echo 'Расход топлива равен - ' . $car1->fuel;
echo "<br>";
echo 'Car1 time' . $car1->tripTime('1000');
echo "<hr>";
$car3 = new Car(234324);
$car3->speed = 3;
echo $car3->brand;
echo "<br>";
echo $car3->speed;
echo "<br>";
echo 'Расход топлива равен - ' . $car3->fuel;
echo "<br>";
echo 'Car1 time' . $car3->tripTime('1000');
echo "<hr>";
//    $car1->test();
//    echo 'Car1 time' . $car1->tripTime('1000');
// $car2 = new Car;
//    $car2->brand = 'Mersedes';
//    $car2->speed = '130';
//    $car2->fuel = '14';
//    $car2->color = 'Black';
//    $car2->test();
//    echo '<pre>';
//    print_r($car1);
//    print_r($car2);
//    echo '</pre>';
//    echo $car2->color;
Пример #2
0
    {
        $result = $this->fuel * $distance / 100;
        return $result;
    }
}
$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>';
//
//