本文整理汇总了PHP中Car::getOwner方法的典型用法代码示例。如果您正苦于以下问题:PHP Car::getOwner方法的具体用法?PHP Car::getOwner怎么用?PHP Car::getOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car::getOwner方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
echo "<p>Changed Speed: </p>";
echo "<p>" . $merc->getcurrentSpeed() . "</p>";
//Accelerate
echo "<p>Accelerated speed : " . $merc->accelerate() . "</p> ";
//Show old gear
echo "<p> Old Gear: " . $merc->getcurrentGear() . " </p>";
//Change the gear
$merc->setCurrentgear(4);
echo "<p>Changed Gear: </p>";
//Show new gear
echo "<p>" . $merc->getCurrentgear() . "</p>";
//Gear Up
echo "<p> GearUp:" . $merc->changeGearUp() . "</p>";
//Gear Down
echo "<p> GearDown:" . $merc->changeGearDown() . "</p>";
//Change Color
$merc->changeColor("pink");
echo "<p> Changed color :" . $merc->getColor() . "</p>";
//Set owner
$merc->setOwner("Voldemor");
echo "<p> And the happy owner of the Mercedez is : " . $merc->getOwner() . " </p>";
//Set owner's age
$merc->setOwnerage(650);
echo "<p> The owner's age is: " . $merc->getOwnerage() . " </p>";
//Price for scrap:
$priceMercforscrap = $merc->calculateCarPriceForScrap(200);
echo "<p> The price for scrap is : " . $priceMercforscrap . " </p>";
?>
</body>
</html>
示例2: changeColor
return $newGeard;
}else{
return false;
};
}
public function changeColor($newColor)
{
$this->setColor($newColor);
}
public function setIsSportscar($isSportscar)
{
$this->isSportscar = $isSportscar;
}
public function getIsSportscar()
{
return $this->isSportscar;
/*
if ($this->isSportscar){
return $this->isSportscar;
} else {
return false;
}
//
}
}
*/
echo "FIRST";
$bmw = new Car("Harry Potter", "bmw", "240", "red", true);
echo $bmw->getOwner();
echo "LAST";
示例3: Car
<?php
require 'autoload.php';
$ferrari = new Car('Ferrari', 400, 0, 'red', 0);
$bmw = new Car('bmw', 320, 0, 'blue', 0);
echo $ferrari->display();
$ferrari->setCurrentGear(3);
$ferrari->setCurrentSpeed(60);
echo $ferrari->display();
$somebody = new Person("Ivan", 36);
$ferrari->setOwner($somebody);
echo $ferrari->getOwner();
$ferrari->accelerate(200);
echo "<br>";
echo $ferrari->getCurrentSpeed();
echo "<br>";
$ferrari->changeGearUp();
echo $ferrari->getCurrentGear();
//$ferrari->accelerate(300);
//echo $ferrari->getCurrentSpeed();