id=$id;
$this->name=$name;
$this->vendor=$vendor;
$this->category=$category;
$this->price=$price;
$this->properties=$properties;
}
private function displayProperties(){
$result='Характеристики:';
foreach($this->properties as $key => $value) {
$result.= $key . ": " . $value;
$result.= "
";
}
return $result;
}
public function displayInfo(){
return $this->id.". ".$this->vendor." ".$this->name."
Ціна: ".$this->price."
Категорія: ".$this->category."
". $this->displayProperties();
}
public function __destruct(){
echo "Data was deleted";
}
}
$nb1= new Backpack(1, 'Flare', 'Osprey','Міські рюкзаки', '999',['Вага'=>'1.1','Об\'єм'=>'20']);
echo $nb1->displayInfo();
class Category{
private $id;
private $name;
public function __construct($id, $name){
$this->id=$id;
$this->name=$name;
}
public function displayInfo(){
return $this->id.". ".$this->name."";
}
public function __destruct(){
echo "Data was deleted";
}
}
$nc1= new Category(1, 'Міські рюкзаки');
echo $nc1->displayInfo();
class Property{
private $id;
private $name;
private $units;
public function __construct($id, $name,$units){
$this->id=$id;
$this->name=$name;
$this->units=$units;
}
public function displayInfo(){
return $this->id.". ".$this->name." (".$this->units.")";
}
public function __destruct(){
echo "Data was deleted";
}
}
$np1= new Property(1, 'Вага', 'кг');
echo $np1->displayInfo();
?>