<?php
class ShopProduct {
public $title;
public $producerMainName;
public $producerFirstName;
public $price;
function __construct($title, $firstName, $mainName, $price){
$this->title = $title;
$this->producerFirstName = $firstName;
$this->producerMainName = $mainName;
$this->price = $price;
}
function getProducer(){
return "{$this->producerFirstName} . {$this->producerMainName}";
}
function getSummaryLine(){
$base = "{$this->title} ({$this->producerMainName}, ";
$base .= "{$this->producerFirstName})";
return $base;
}
} //end class ShopProduct
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 = "$this-.title ($this->producerMainName, ";
$base .= "$this->producerFirstName )";
$base .= ": page count - $this->numPages";
return $base;
}
} //end class CdProduct
class BookProduct extends ShopProduct {
public $numPages;
function __construct($title, $firstName, $mainName, $price, $numPages){
parent::__construct($title, $firstName, $mainName, $price);
$this->numPages = $numPages;
}
function getNumberOfPages(){
return $this->numPages;
}
function getSummaryLine(){
$base = "$this->title ($this->producerMainName, ";
$base .= "$this->producerFirstName)";
$base .= ": page count - $this->numPages";
return $base;
}
}
?>
No comments:
Post a Comment