Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.
class Vehicle {
var $price;
function & _instance($vehicle)
{
$class = 'Vehicle_' . $vehicle;
$file = 'Vehicle_'.$vehicle.'.php';
include($file);
$instance = & new $class;
return $instance;
}
}
class Vehicle_Car extends Vehicle {
var $price = 1000;
}
class Vehicle_Bike extends Vehicle {
var $price = 2000;
}
class basket()
{
var $basketitems = array();
var $sumtotal = 0;
function addtoBasket($vehicle){
}
function getTotalCost(){
}
}
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
Okay, I think the confusing thing here is that basket isn't a client of the factory. Basket is using the products themselves, not the factory. Take a look at the simple example here:
http://en.wikipedia.org/wiki/Factory_method_pattern#Example
PIzzaLover (the class at the bottom) is the client in this example.