Hi All,
Im after some advice on extending classes.
ive got a vehicle class, which is extended by the motorcycle class.
my question is how do i create a class of the motor cycle that includes the vehicle class elements.
<?php
class vehicle {
private $wheels;
private $engineType;
private $engineSize;
private $color;
function __construct($wheels, $engineType, $engineSize, $color){
$this->wheels = $wheels;
$this->engineType = $engineType;
$this->engineSize = $engineSize;
$this->color = $color;
}
public function getWheels(){
return $this->wheels;
}
}
class motorcycle extends vehicle {
private $sidecar;
private $handlebars;
function __construct($sidecar, $handlebars){
$this->sidecar = $sidecar;
$this->handlebars = $handlebars;
}
public function getSideCar(){
return $this->sidecar;
}
}
$vehicle = new vehicle (2, 1500, 1.2, "red");
echo $vehicle->getWheels();
echo "<br>";
echo $vehicle->test();
?>