<?php

abstract class Book
{
	// public $format = ['HARD', 'POCKET'];
	protected $_price;

	public function __construct($price)
	{
		$this->_price = setPrice($price);
	}

	public function setPrice($price)
	{   
		if ($price > 0)  { 
		 	$this->_price= $price;
		} else { 
			throw new Exception("Price cannot be less than 0");        
		}  
	}

	public function getPrice()
	{   
		return $this->_price;  
	}


}

class Hard extends Book
{
	
	public function __construct($price){
		$this->setPrice($price);
	}
	
	public function setPrice($price){
		$this->_price= $price+ $price * 1/4;
	}
}

class Pocket extends Book
{
	public function __construct($price){
		$this->setPrice($price);
	}
	
}
class BookFactory
{
	
	public static function add($format, $price){
		$format = ucwords($format);
		if(class_exists($format)) {
           return new $format($price);
		} else {
			throw new Exception('Format not supported.');
		}
	}
	
}

$book1 = BookFactory::add('HARD',600);
echo "The " . get_class($book1) . " is \${$book1->getPrice()}";
echo "\r\n"; 
$book2 = BookFactory::add('pocket',600);
echo "The " . get_class($book2) . " is \${$book2->getPrice()}";