Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html lang="ru">
- <head>
- <title>ТиОПО</title>
- <meta charset="utf-8">
- </head>
- </html>
- <?php
- class Product {
- public $weight;
- public $price;
- function About() {
- return "Вес: $this->weight Цена: $this->price";
- }
- }
- class milkProduct extends Product {
- public $some_name;
- public function __construct($weight, $price, $name)
- {
- $this->weight = $weight;
- $this->price = $price;
- $this->some_name = $name;
- }
- }
- class chocolateProduct extends Product {
- public $some_name;
- public function __construct($weight, $price, $name)
- {
- $this->weight = $weight;
- $this->price = $price;
- $this->some_name = $name;
- }
- }
- class candyProduct extends Product {
- public $some_name;
- public function __construct($weight, $price, $name)
- {
- $this->weight = $weight;
- $this->price = $price;
- $this->some_name = $name;
- }
- }
- $milk = new milkProduct('123', '321', 'КРЯ1');
- $chocolate = new chocolateProduct('321', '123', 'КРЯ2');
- $candy = new candyProduct('567', '765', 'КРЯ3');
- echo $milk->some_name." | ".$milk->About()."<br/>";
- echo $chocolate->some_name." | ".$chocolate->About()."<br/>";
- echo $candy->some_name." | ".$candy->About()."<br/>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement