<?php /** * Copyright (c) 2014 Keith Casey * * This code is designed to accompany the lynda.com video course "Design Patterns in PHP" * by Keith Casey. If you've received this code without seeing the videos, go watch the * videos. It will make way more sense and be more useful in general. */ include_once 'vehicle.php'; $car = new Car(4); echo $car->getType(); echo '<br />'; $truck = new Truck(18); echo $truck->getType();
include "Vehicle.php"; class Car extends Vehicle { private $noOfDoors; private $color; private $brand; public function __construct($cc, $hp, $noOfDoors, $color, $brand) { echo "<br/>Hi from car constructor"; parent::__construct('Car', $cc, $hp); $this->noOfDoors = $noOfDoors; $this->color = $color; $this->brand = $brand; } public function getColor() { return $this->color; } public function getNoOfDoors() { return $this->noOfDoors; } public function getBrand() { return $this->brand; } } $v = new Car(1.3, 100, 4, 'Golden', 'BMW'); echo "<br/>Type is " . $v->getType() . ", CC : " . $v->getCc() . ", HP : " . $v->getHp() . ", Color : " . $v->getColor() . ", Brand : " . $v->getBrand();