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 Carro { | |
private $motor; | |
public function __construct(Motor $motor) { | |
$this->motor = $motor; | |
$this->motor->arranca(); | |
} | |
} |
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 Motor { | |
public function __construct(){} | |
public function arranca() { | |
return "run run run run..."; | |
} | |
} | |
class MotorDiesel extends Motor { | |
public function __construct() {} | |
} |
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 Motor { | |
private $prendido; | |
public function __construct() {} | |
public function arranca() { | |
if(!$this->prendido) { | |
echo "run run run run..."; | |
$this->prendido = true; | |
} else { | |
throw new Exception("Ehh!! Ya estoy prendido me vas a descomponer!!"); |
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 | |
abstract class Motor { | |
const DIESEL = 0; | |
const GASOLINA = 1; | |
const BIODIESEL = 2; | |
protected $encendido = false; | |
protected $cilindros; | |
public function enciende() { |
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 MotorDiesel extends Motor { | |
public function __construct($cilindros) { | |
$this->cilindros = $cilindros; | |
} | |
} | |
class MotorGasolina extends Motor { | |
public function __construct($cilindros) { | |
$this->cilindros = $cilindros; |
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); |
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 | |
$camioneta = CarrosFactory::crearCarro(MOTOR::DIESEL, 8); | |
$sedan = CarrosFactory::crearCarro(MOTOR::GASOLINA, 4); | |
$autobus = CarrosFactory::crearCarro(MOTOR::DIESEL, 8); | |
$hibrido = CarrosFactory::crearCarro(MOTOR::BIODIESEL, 4); | |
$camioneta->enciende(); | |
$sedan->enciende(); | |
$autobus->enciende(); | |
$hibrido->enciende(); |
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
var dominioValido:String = "alanchavez.com"; | |
var dominioQueCarga:String = this.root.loaderInfo.url.split("/")[2]; | |
trace("Ubicacion de la película=" + dominioQueCarga); | |
if (dominioQueCarga.indexOf(dominioValido) != (dominioQueCarga.length - dominioValido.length)) { | |
dominioNoPermitido(); | |
} | |
function dominioNoPermitido():void { | |
trace("Hola estimado visitante. Permiteme informarte que yo, el administrador de "+dominioQueCarga+" soy un rata cola larga, y esta película fue especialmente programada para ser visualizada en "+dominioValido+" y en unos momentos seras redireccionado a la página del autor original. Gracias"); | |
navigateToURL(new URLRequest("http://www.alanchavez.com"),'newwindow'); |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
// crea conexion local | |
var receive_lc:LocalConnection = new LocalConnection(); | |
// permite comunicacion entre SWFs entre diferentes dominios | |
receive_lc.allowDomain("*"); | |
// Espera por conexiones entrantes. | |
// Este comando tiene que ejecutarse ANTES de que el otro SWF envie información. | |
receive_lc.connect("_connection1"); |