Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Car
- {
- public $brand;
- public $price;
- function isExpensive() {
- if ("{$this->price}" > 650000) {
- return "Да";
- } else {
- return "Нет";
- }
- }
- }
- $id1 = new Car();
- $id2 = new Car();
- $id1->brand = 'БМВ';
- $id2->brand = 'Ауди';
- $id1->price = 600000;
- $id2->price = 700000;
- //Телевизор
- class TV
- {
- public $brand;
- public $size;
- function getBigSize() {
- if ("{$this->size}" > 41) {
- return true;
- }
- }
- }
- $id1 = new TV();
- $id2 = new TV();
- $id1->brand = 'Сони';
- $id2->brand = 'Филипс';
- $id1->size = 42;
- $id2->size = 40;
- //Шариковая ручка
- class Pen
- {
- public $color;
- public $type;
- function getDescription() {
- return "{$this->color} {$this->type}";
- }
- }
- $id1 = new Pen();
- $id2 = new Pen();
- $id1->color = 'Черная';
- $id2->color = 'Синяя';
- $id1->type = 'Шариковая';
- $id2->type = 'Гелевая';
- //Утка
- class Duck
- {
- public $name;
- public $whereIs;
- function sayKryaKrya() {
- return "{$this->name} сказал КРЯ-КРЯ";
- }
- }
- $id1 = new Duck();
- $id2 = new Duck();
- $id1->name = 'Чёрный плащ';
- $id2->name = 'Скрудж МакДак';
- $id1->whereIs = 'На месте';
- $id2->whereIs = 'Зимует';
- //Товар
- class Item
- {
- public $count;
- public $available;
- function isAvailable() {
- if ("{$this->available}" == true) {
- return "В наличии {$this->count} шт.";
- } else {
- return "Товара нет в наличии";
- }
- }
- }
- $id1 = new Item();
- $id2 = new Item();
- $id1->count = 100;
- $id2->count = 200;
- $id1->available = true;
- $id2->available = false;
Advertisement
Add Comment
Please, Sign In to add comment