<?php
namespace Main\Product;

require_once 'Product.php';	// Include the code from package Object.php
									// can be written require_once("Object.php");
									// although it is a language construct not a function

// Product and CD are both part of the \Main\Product namespace
// so new "use" statement is required.

// If you don't want to allow subclassing of CD
// mark it with "final".
// final class CD
// {
// }
//
class CD extends Product
{
	// Attributes
	private $_artist;
	private $_tracks;
	
	// Constructor
	public function __construct($name, $price, $artist, $tracks)
	{
		// Call the parent classes constructor to
		// store the name and price
		parent::__construct($name, $price);
		
		$this->_artist = $artist;
		$this->_tracks = $tracks;
	}
	
	// Methods for properties
	// Getters and Setters
	public function GetArtist()
	{
		return $this->_artist;	
	}
	
	public function SetArtist($value)
	{
		$this->_artist = $value;
		return;
	}
	
	public function GetTracks()
	{
		return $this->_tracks;	
	}
	
	public function SetTracks($value)
	{
		$this->_tracks = $value;
		return;
	}
	
	// Methods
	// Override the calculation...polymorphism
	public function CalculateTax()
	{
		$tax = parent::CalculateTax();			// Let Product class calculate tax based on price
		
		// Add tax per track
		$tax = $tax + count($this->_tracks) * 0.30;	// 30p per track
		
		return $tax;
	}
}
?>