本文整理汇总了PHP中Car::move方法的典型用法代码示例。如果您正苦于以下问题:PHP Car::move方法的具体用法?PHP Car::move怎么用?PHP Car::move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car::move方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: move
public function move($distance)
{
// $this->money = 0 + 10*0.65 = 6.5
$result = parent::move($distance);
if ($result == true) {
$this->money = $this->money + $distance * $this->price_per_km;
} else {
echo "Nema nafta";
}
}
示例2: __construct
{
public function __construct($x = 0, $y = 0)
{
parent::__construct($x, $y);
}
//это делать не обязательно берет из родительского конструктора
public function move($x, $y)
{
$this->strMove($x, $y, "легковой");
}
}
class Truck extends Auto
{
private $capasity;
public function __construct($x = 0, $y = 0, $capasity = 5000)
{
parent::__construct($x, $y);
$this->capasity = $capasity;
}
//это делать не обязательно берет из родительского конструктора
public function move($x, $y)
{
$this->strMove($x, $y, "грузовой");
}
}
$auto = new Auto();
$car = new Car();
$truck = new Truck();
$auto->move(10, 10);
$car->move(10, 10);
$truck->move(10, 10);
示例3: Car
<?php
require_once "car.php";
require_once "truck.php";
require_once "taxi.php";
$car = new Car(1, 'Black', 5);
$result = $car->move(100);
if ($result == true) {
echo "We are magicians";
} else {
echo "Sipi nafta";
}
exit;
// fuel, color, number , perKm, startingMoney, seats
$taxi = new Taxi(30, 'Black & Yellow', '6665', '0.65', 0, 4);
echo "<pre>";
print_r($taxi);
$taxi->move(10);
echo "<pre>";
print_r($taxi);
$taxi->move(6);
echo "<pre>";
print_r($taxi);
$taxi->move(200);
echo "<pre>";
print_r($taxi);
$taxi->move(100);
echo "<pre>";
print_r($taxi);