id=$id;
$this->name=$name;
}
public function display(){
echo $this->id.". ".$this->name."";
}
public function update($id, $name){
$this->id=$id;
$this->name=$name;
}
public function __destruct(){
$this->id=null;
$this->name=null;
}
}
class Property extends BaseEntity{
private $name;
private $units;
public function __construct($id, $name, $units){
$this->id=$id;
$this->name=$name;
$this->units=$units;
}
public function display(){
echo $this->id.". ".$this->name." (".$this->units.")";
}
public function update($id, $name, $units){
$this->id=$id;
$this->name=$name;
$this->units=$units;
}
public function __destruct(){
$this->id=null;
$this->name=null;
$this->units=null;
}
}
class Backpack extends BaseEntity{
private $model;
private $vendor;
private $price;
private $category;
private $properties;
public function __construct($id, $model,$vendor,$price,$category,$properties){
$this->id=$id;
$this->model=$model;
$this->vendor=$vendor;
$this->price=$price;
$this->category=$category;
$this->properties=$properties;
}
public function display(){
echo $this->id.". ".$this->vendor." ".$this->model."";
echo "Категорія: ".$this->category."";
echo "Ціна: ".$this->price." грн";
echo "Характеристики:";
foreach (json_decode($this->properties) as $propertyName => $propertyValue) {
echo $propertyName . ": " . $propertyValue . "";
}
}
public function update($id, $model,$vendor,$price,$category,$properties){
$this->id=$id;
$this->model=$model;
$this->vendor=$vendor;
$this->price=$price;
$this->category=$category;
$this->properties=$properties;
}
public function __destruct(){
$this->id=null;
$this->model=null;
$this->vendor=null;
$this->price=null;
$this->category=null;
$this->properties=null;
}
}
$a=new Property(1, "Вага", "кг");
$a->display();
/*$a=new Backpack(1,"Flare", "Osprey","2000","Міські рюкзаки", '{"Вага":"0.8 кг", "Об\'єм":"60 л"}');
$a->display();*/
/*$a=new Category(1,"Похідні рюкзаки");
$b=new Category(2,"Міські рюкзаки");
$a->display();
$b->display();
$a->update(1,"Експедиційні рюкзаки");
$a->display();*/
?>