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


PHP Car::changeGearDown方法代码示例

本文整理汇总了PHP中Car::changeGearDown方法的典型用法代码示例。如果您正苦于以下问题:PHP Car::changeGearDown方法的具体用法?PHP Car::changeGearDown怎么用?PHP Car::changeGearDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Car的用法示例。


在下文中一共展示了Car::changeGearDown方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Person

require_once 'autoload.php';
$owner1 = new Person('Ivan', 19);
$peugeot = new Car('Peugeot', '2011', 'black', 5, 180, $owner1);
$peugeot->setCurrentGear('2');
$peugeot->setCurrentSpeed('32');
//var_dump($peugeot);
$peugeot->changeGear(8);
$peugeot->changeSpeed(100);
$peugeot->changeSpeed(190);
//var_dump($peugeot);
$owner2 = new Person('Dragan', 29);
$audi = new Car('Audi', '2012', 'green', 6, 230, $owner2);
$audi->setCurrentGear('3');
$audi->setCurrentSpeed('65');
//var_dump($audi);
$audi->changeGear(8);
$audi->changeGear(4);
$audi->changeSpeed(150);
$audi->changeSpeed(250);
/*var_dump($audi);

var_dump($owner1->getAge().' '. $owner1->getName());
var_dump($audi->display());
var_dump($peugeot->display());*/
$audi->changeGearDown();
$audi->changeGearUp();
$audi->changeGearUp();
$audi->changeGearUp();
$audi->changeGearUp();
var_dump($audi);
开发者ID:hristopetrov,项目名称:HomeworkOOP,代码行数:30,代码来源:car-demo.php

示例2:

//Show new speed
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>
开发者ID:ivanstoykovivanov,项目名称:IT_Talents_Homework_Classes,代码行数:31,代码来源:Demo.php


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