class cd {
public $artist;
public $title;
protected $tracks;
private $disk_id;
public function __construct() {
$this->disk_id = sha1('cd' . time() . rand());
}
public function get_disk_id() {
return $this->disk_id;
}
}
class cd_album extends cd {
protected $num_disks;
public function __construct($disks = 1) {
$this->num_disks = $disks;
parent::__construct();
}
public function is_multi_cd() {
return ($this->num_disks > 1) ? true : false;
}
}
$mydisk = new cd_album(3);
echo 'The compact disk ID is: ', $mydisk->get_disk_id(), '
';
echo 'Is this a multi cd? ',
($mydisk->is_multi_cd()) ? 'Yes' : 'No',
'
';
?>