示例#1
0
 public function __construct()
 {
     parent::__construct(self::className, self::classPrice);
     $this->equipCar();
 }
<?php

require_once "Automobile.php";
$make = 'vw';
$model = 'bug';
$color = 'papayawhip';
$car1 = new Automobile($make, $model, $color);
echo $car1->getDescription() . PHP_EOL;
$yourCar = new Automobile('audi', 'zippy-fast', 'pink');
echo $yourCar->getDescription() . PHP_EOL;
    public $make;
    public $model;
    public $color;
    public function honk()
    {
        return 'BEEP BEEP';
    }
    public function accelerate()
    {
        return $this->increaseFuelAirMixture;
    }
    public function increaseFuelAirMixture()
    {
        // api to the fuel injection
    }
    public function brake()
    {
        return $this->engageBrakePads;
    }
    public function engageBrakePads()
    {
        //api to the brake pads
    }
}
// end of Automobile
$newcar = new Automobile();
$newcar->make = 'Dodge';
$newcar->model = 'Challenger';
$newcar->color = 'Jet Black';
$newcar->brake();
var_dump($newcar);
示例#4
0
<?php

require 'classes.php';
$auto = new Automobile();
$model = new BaseAutomobileModel();
$model = new SportAutomobileModel($model);
$model = new TouringAutomobileModel($model);
$auto->setModel($model);
$auto->printDescription();
<?php

require_once "Automobile.php";
$make = 'vw';
$model = 'bug';
$color = "papayawhip";
$car1 = new Automobile($make, $model, $color);
echo $car1->getDescription();
$yourCar = new Automobile('audi', 'A4', 'pink');
echo $yourCar->getDescription();
die;
示例#6
0
 public function calcVehiclePriceWithDiscount(Automobile $car)
 {
     $finalPrice = $car->calculatePrice();
     foreach ($this->discountOptions as $option) {
     }
 }
示例#7
0
<?php

require_once "Automobile.php";
$make = "vw";
$model = "bug";
$color = "blue";
$car1 = new Automobile($make, $model, $color);
echo $car1->getDescription();