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


PHP Car::getCurrentGear方法代码示例

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


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

示例1: Car

var_dump($nissanSport);
echo "<p> New sports car constructor used: Nissan : " . $nissanSport->getModel() . " </p>";
echo "<p> Sports car? : " . $nissanSport->getIsSportscar() . "</p>";
echo "<p> Sports car speed : " . $nissanSport->getMaxspeed() . "</p>";
$priceNissanforscrap = $nissanSport->calculateCarPriceForScrap(200);
echo "<p> The price for scrap is : " . $priceNissanforscrap . " </p>";
echo "<hr>";
//-------------------------------------------------------------------------------//
//Second Car :Mercedez
$merc = new Car("Voldemor", "mercedez-benz", "220", "silver", false);
echo "<h3>Car 2 (merc) properties: " . $merc->getColor() . "</h3>";
echo "<p>" . $merc->getModel() . "</p>";
echo "<p>" . $merc->getMaxspeed() . "</p>";
echo "<p>" . $merc->getcurrentSpeed() . "</p>";
echo "<p>" . $merc->getColor() . "</p>";
echo "<p>" . $merc->getCurrentGear() . "</p>";
//Show old speed
echo "<p> Old Speed: " . $merc->getcurrentSpeed() . " </p>";
//Change the speed
$merc->setcurrentSpeed(60);
//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
开发者ID:ivanstoykovivanov,项目名称:IT_Talents_Homework_Classes,代码行数:31,代码来源:Demo.php

示例2: Car

<?php

require_once 'autoload.php';
$car1 = new Car('BMW', true, 'black', 340000, 250);
$car1->setCurrentSpeed(100);
$car1->setCurrentGear(4);
$car2 = new Car('Audi', false, 'grey', 280000, 260);
$car2->setCurrentSpeed(150);
$car2->setCurrentGear(5);
echo "Gear is: ", $car1->getCurrentGear(), " and the speed is: ", $car1->getCurrentSpeed(), PHP_EOL;
$car1->changeGear(5);
$car1->accelerate();
echo "Now the gear is: ", $car1->getCurrentGear(), " and the speed is: ", $car1->getCurrentSpeed(), PHP_EOL;
$shop = new CarShop();
$shop->addCar($car1);
$shop->addCar($car2);
$shop->showAllCarsInTheShop();
开发者ID:yoannamiteva,项目名称:it_talents,代码行数:17,代码来源:car_demo.php

示例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();
开发者ID:KostadinStefanov,项目名称:IT-Talents-HomeWork-OOP-Intro,代码行数:20,代码来源:carDemo.php


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