/////////////////////////////////////////////Task 5 /////////////////////////////////////////
ECHO '
Task 5:
';
//Object class Vehicles have 2 properties( make and model )
class Vehicles{
//The private variables holds the object information locally and
//can then be accessed by using relevant public get and set methods.
private $make, $model;
//The construct method sets the object properties when the object is created.
public function __construct($make, $model){
$this->make = $make;
$this->model = $model;
echo $this->get_Formatted_Description();
}
//Set methods if you want to change the make or model
//you can implement bussiness rules in the set method to prevent data issues.
//like changing the make if the model is already set could cause an invalid vehicle.
public function set_Make($NewMake){
$this->make = $NewMake;
}
public function set_Model($NewModel){
$this->model = $NewModel;
}
//Get methods if you want to Access the make or model
//you can implement bussiness rules in the get method to format the output or do
//Data conversion.
public function get_Make(){
return $this->make;
}
public function get_Model(){
return $this->model;
}
public function get_Formatted_Description(){
$strRet = "The make is $this->make, the model is the $this->model.";
return $strRet;
}
}
//Create a new instance of the Vehicles class.
$MyCar = new Vehicles("Mercedes Benz","500S");