assessmentee.com

Home | Start test | Contact
 

Activerecord | Adapter | Decorator | DependencyInjectionContainer | Facade | Factory | Hydration | Inheritance | Iterator | Mapper | MVC | Observer | Prototype | Proxy | Registry | ServiceLocator | Singleton | Specification | Strategy | TableGateway | ZF1_TableGateway | ZF2_TableGateway |




    <?php

/**
 * Simple multiple inheritance pattern
 * Start at the specific
 * End with the general
 */

class Businesses {
 public function getSector(){
        return sprintf("a %s is part of the for-profit sector<br>",$this->sector);
    }
}

class Shops extends Businesses {
    protected $sector = 'business';
     public function getIndustry(){
        return sprintf("%s is a retail business <br>",$this->name);
    }
}

class BicycleShop extends Shops {
     protected $name = 'antilope';
}

$bicycleShop = new BicycleShop();
echo $bicycleShop->getIndustry();
echo $bicycleShop->getSector();
    

Outputs:


antilope is a retail business
a business is part of the for-profit sector



 

© 2018 assessmentee.com