book_page_118

 avatar
user_7141235750
php
3 years ago
799 B
6
Indexable
<?php 

class Product{
	protected $id;
	protected $title;
	protected $price;

	function __construct($id, $title, $price){
		echo "<br>Product constructor :-- <br>";
		$this->id = $id;
		$this->title = $title;
		$this->price = $price;
	}

	public function setProduct($id, $title, $price){
		$this->id = $id;
		$this->title = $title;
		$this->price = $price;
	}

	public function showInfo(){
		echo "<br>--Product Info--<br>";
		echo "Title : {$this->title} <br>";
		echo "Price : {$this->price} Taka <br>";
	}

}

class Book extends Product{    //inheritance

}

class CD extends Product{    //inheritance

}

$book = new Book(1, "OOP PHP", 750.00);
$book->showInfo();

$cd = new CD(2, '"ঠাকুরমার ঝুলি"', 350.00);
$cd->showInfo();

?>
Editor is loading...