Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $db = new sqlite_db("db.sqlite");
- $db->query
- ("BEGIN;
- CREATE TABLE products ( id INEGER PRIMARY KEY AUTOINCREMENT,
- type TEXT,
- firstname TEXT,
- mainname TEXT,
- title TEXT,
- price float,
- numpage int,
- playlength int,
- discount int
- COMMIT;");
- class ShopProduct
- {
- private $title;
- private $producerFirstName;
- private $producerMainName;
- protected $price;
- private $discount = 0;
- private $id = 0;
- public function __construct($title, $firstName, $mainName, $price)
- {
- $this->title =$title;
- $this->producerFirstName =$firstName;
- $this->producerMainName =$mainName;
- $this->price =$price;
- }
- public function getTitle()
- {
- return $this->title;
- }
- public function getProducer()
- {
- return $this->producerFirstName . $this->producerMainName;
- }
- public function getSummaryLine()
- {
- $base = $this->title . $this->producerFirstName . $this->producerMainName;
- return $base;
- }
- public function getDiscount()
- {
- return $this->discount;
- }
- public function setDiscount($num)
- {
- $this->discount=$num;
- }
- public function getPrice()
- {
- return ($this->price - $this->discount);
- }
- }
- /**
- *
- */
- class CDproduct extends ShopProduct
- {
- private $playLength;
- public function __construct( $title, $firstName, $mainName, $price, $playLength)
- {
- parent::__construct($title, $firstName, $mainName, $price);
- $this->playLength = $playLength;
- }
- public function getPlayLength()
- {
- return $this->playLength;
- }
- public function getSummaryLine()
- {
- $base = parent::getSummaryLine();
- $base .= ": play - {$this->playLength} ";
- return $base;
- }
- }
- /**
- *
- */
- class BookProduct extends ShopProduct
- {
- private $numPages;
- public function __construct( $title, $firstName, $mainName, $price, $numPages)
- {
- parent::__construct($title, $firstName, $mainName, $price);
- $this->numPages = $numPages;
- }
- public function getNumPages()
- {
- return $this->numPages;
- }
- public function getSummaryLine()
- {
- $base = parent::getSummaryLine();
- $base .= ": {$this->numPages} str.";
- return $base;
- }
- public function getPrice()
- {
- return $this->price;
- }
- }
- class ShopProductWriter
- {
- private $products = array();
- public function addProduct ( ShopProduct $shopProduct )
- {
- $this->products[] = $shopProduct;
- }
- public function write()
- {
- $str = "";
- foreach ($this->products as $shopProduct)
- {
- $str .= "{$shopProduct->getTitle}: ";
- $str .= $shopProduct->getProducer();
- $str .= "({$shopProduct->getPrice()})\n";
- }
- print $str;
- }
- }
- ?>
- <?
- class StaticExample
- {
- static public $aNum;
- static public function sayHello($aNum)
- {
- print "hell (" . self::$aNum=1 .")";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment