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


PHP Car::getPrice方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:gpichurov,项目名称:ittalents_season5,代码行数:7,代码来源:Person.php

示例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! ';
     }
 }
开发者ID:nicoleip,项目名称:OOP_Homework,代码行数:12,代码来源:Person.php

示例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;
     }
 }
开发者ID:ivanstoykovivanov,项目名称:IT_Talents_Homework_Classes,代码行数:13,代码来源:Person.php

示例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);
开发者ID:SCARFACET0NY,项目名称:Homework,代码行数:30,代码来源:12.php

示例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;
开发者ID:jeffaustin81,项目名称:car_application,代码行数:31,代码来源:app.php

示例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;
开发者ID:slmaturen,项目名称:Car_Dealership_With_Twig,代码行数:31,代码来源:app.php


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