Skip to content

Instantly share code, notes, and snippets.

@sorbing
Created October 12, 2012 11:39
Show Gist options
  • Save sorbing/3878815 to your computer and use it in GitHub Desktop.
Save sorbing/3878815 to your computer and use it in GitHub Desktop.
class Cars
{
function createCar($brand)
{
$car_obj = 0;
switch ($brand) {
case 'toyota': $car_obj = new Toyota;
case 'bmw': $car_obj = new Bmw;
default: $car_obj = new Toyota;
}
return $car_obj;
}
}
abstract class Car
{
abstract function getMaxSpeed();
abstract function getWeight();
}
class Toyota extends Car
{
public function getMaxSpeed() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment