@ 2016-01-07T21:53:02Z <?php
class ShopProduct
{
public $discount = 0;
public $title;
public $producerMainName;
public $producerFirstName;
protected $price;
function __construct($title, $firstName, $mainName, $price)
{
$this->title = $title;
$this->producerFirstName = $firstName;
$this->producerMainName = $mainName;
$this->price = $price;
}
function getSummaryLine(){
$base = "{$this->title} ( {$this->producerMainName}, ";
$base .= "{$this->producerFirstName} )";
return $base;
}
function getProducer() {
return "{$this->producerFirstName} " . "{$this->producerMainName}";
}
function setDiscount(){
$this->discount=$num;
}
public function getPrice()
{
# code...
return ($this->price - $this->discount);
}
}
class ShopProductWriter(){
private $products = array();
public function addProduct( ShopProduct $shopProduct){
$this->product[] = $shopProduct;
}
public function write(){
$str = "";
foreach ($this->products as $shopProduct) {
$str .= "{$shopProduct->title}: ";
$str .= "{$shopProduct->getProducer()}";
$str .= "{$shopProduct->getPrice()}\n";
}
print $str;
}
}
class CDProduct extends ShopProduct {
public $playLength;
function __construct($title, $firstName, $mainName, $price, $playLength){
parent::__construct($title, $firstName, $mainName, $price);
$this->playLength = $playLength;
}
function getPlayLength(){
return $this->playLength;
}
function getSummaryLine(){
$base = parent::getSummaryLine();
$base .= " :Legth of song {$this->playLength}";
return $base;
}
}
class BookProduct extends shopProduct{
public $numPages;
function __construct($title, $firstName, $mainName, $price, $numPages){
parent::__construct($title, $firstName, $mainName, $price);
$this->playLength = $playLength;
}
function getSummaryLine(){
$base = parent::getSummaryLine();
$base .= ": Number of pages - {$this->numPages}";
}
function getProducer() {
return "{$this->producerFirstName} " . "{$this->producerMainName}";
}
function getPrice(){
return $this->price;
}
}
$product2 = new CDProduct("On my own", "Ashes", "Remain", 10.99, 2.53);
$product3 = new CDProduct("On my own", "Ashes", "Remain", 10.99, 2.53);
$product4 = new CDProduct("On my own", "Ashes", "Remain", 10.99, 2.53);
$product5 = new CDProduct("On my own", "Ashes", "Remain", 10.99, 2.53);
print write();
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.0.2 0.027 0.050 20.27 7.0.1 0.010 0.087 20.23 7.0.0 0.007 0.040 20.07 5.6.17 0.030 0.050 20.56 5.6.16 0.003 0.090 20.71 5.6.15 0.010 0.073 18.27 5.6.14 0.007 0.047 18.18 5.6.13 0.007 0.057 18.21 5.6.12 0.013 0.080 21.00 5.6.11 0.013 0.083 21.02 5.6.10 0.013 0.073 21.03 5.6.9 0.013 0.077 21.01 5.6.8 0.003 0.067 20.36 5.5.31 0.023 0.080 20.32 5.5.30 0.003 0.043 18.04 5.5.29 0.000 0.050 17.95 5.5.28 0.000 0.050 20.66 5.5.27 0.013 0.043 20.90 5.5.26 0.003 0.080 20.70 5.5.25 0.003 0.073 20.63 5.5.24 0.030 0.060 20.13
preferences:dark mode live preview
143.32 ms | 1394 KiB | 7 Q