Last active
December 31, 2015 11:29
-
-
Save azcdev/7979954 to your computer and use it in GitHub Desktop.
Implementacion de Factory en PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CarrosFactory { | |
public function __construct(); | |
public static function crearCarro($tipoMotor, $cilindros) { | |
switch($tipoMotor) { | |
case MOTOR::DIESEL: | |
return new CarroDiesel($cilindros); | |
break; | |
case MOTOR::GASOLINA: | |
return new CarroGasolina($cilindros); | |
break; | |
case MOTOR::BIODIESEL: | |
return new CarroBiodiesel($cilindros); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment