本文整理汇总了PHP中Car::getPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Car::getPrice方法的具体用法?PHP Car::getPrice怎么用?PHP Car::getPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car::getPrice方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buyCar
public function buyCar(Car $car)
{
if ($this->getMoney() >= $car->getPrice()) {
$this->setMoney($this->getMoney() - $car->getPrice());
$this->setCar($car);
}
}
示例2: buyCar
public function buyCar(Car $car)
{
if ($this->money >= $car->getPrice()) {
$this->money -= $car->getPrice();
echo ' Purchase successful!', PHP_EOL;
$this->car = $car;
$car->changeOwner($this);
return $this->money;
} else {
echo ' You need more money! ';
}
}
示例3: buyCar
public function buyCar($car)
{
$car = new Car();
$carPrice = $car->getPrice();
//return $car->getModel;
if ($this->money > $carPrice) {
$this->ownedCar = $car;
return $carPrice;
//$this->money -= $carPrice;
} else {
return $this->money;
}
}
示例4: showBrand
{
public $brand;
public $model;
public $year;
public $driver;
private $price;
public function showBrand()
{
echo $this->brand;
}
public function showModel()
{
echo $this->model;
}
public function setPrice($price)
{
$this->price = round($price, 2);
}
public function getPrice($bool)
{
if ($bool === true) {
return number_format($this->price, 2, '.', ',');
} else {
return $this->price;
}
}
}
$bmw = new Car();
$bmw->setPrice(25700.358);
echo $bmw->getPrice(true);
示例5: function
$app->get('/', function () use($app) {
return $app['twig']->render('home.html.twig');
});
$app->get('/post', function () use($app) {
return $app['twig']->render('cars.html.twig', array('cars' => Car::getAll()));
});
$app->get("/search", function () use($app) {
return $app['twig']->render('search_cars.html.twig');
});
$app->post("/cars", function () use($app) {
$car = new Car($_POST['model'], $_POST['price'], $_POST['miles'], $_POST['image_path']);
$car->save();
return $app['twig']->render('create_car.html.twig', array('newcar' => $car));
});
$app->post("/delete_car", function () use($app) {
Car::deleteAll();
return $app['twig']->render('delete_cars.html.twig', array('cars' => Car::getAll()));
});
$app->get("/view_car", function () use($app) {
$cars_matching_search = array();
$cars = Car::getAll();
$user_price = $_GET["price"];
$user_miles = $_GET["miles"];
foreach ($cars as $car) {
if ($car->getPrice() < $user_price && $car->getMiles() < $user_miles) {
array_push($cars_matching_search, $car);
}
}
return $app['twig']->render('car_posting.html.twig', array('cars' => $cars_matching_search));
});
return $app;
示例6: array
// Direct app to twig.path
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
// Home page: car search form.
$app->get("/", function () use($app) {
return $app['twig']->render('cars.html.twig', array('cars' => Car::getAll()));
});
// Page: car newly added.
$app->post('/car_added', function () use($app) {
$car = new Car($_POST['model'], $_POST['price'], $_POST['miles'], $_POST['image']);
$car->save();
return $app['twig']->render('car_added.html.twig', array('newcar' => $car));
});
// Page: Delete cars
$app->post('/delete_cars', function () use($app) {
Car::deleteAll();
return $app['twig']->render('delete_cars.html.twig');
});
// Page: results display.
$app->get('/results', function () use($app) {
// $cars = array(Car::getAll());
$cars_we_want = array();
foreach ($_SESSION['list_of_cars'] as $car) {
if ($car->getPrice() < $_GET["price"] && $car->getMiles() < $_GET["miles"]) {
array_push($cars_we_want, $car);
}
}
// Set the array "cars" as equal to "$cars_we_want", pass it to results page
return $app['twig']->render('results.html.twig', array('cars' => $cars_we_want));
});
return $app;