dergunovs

Untitled

May 11th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. <?php
  2. class Car
  3. {
  4.     public $brand;
  5.     public $price;
  6.  
  7.     function isExpensive() {
  8.         if ("{$this->price}" > 650000) {
  9.             return "Да";
  10.         } else {
  11.             return "Нет";
  12.         }
  13.     }
  14. }
  15.  
  16. $id1 = new Car();
  17. $id2 = new Car();
  18.  
  19. $id1->brand = 'БМВ';
  20. $id2->brand = 'Ауди';
  21. $id1->price = 600000;
  22. $id2->price = 700000;
  23.  
  24.  
  25. //Телевизор
  26.  
  27. class TV
  28. {
  29.     public $brand;
  30.     public $size;
  31.  
  32.     function getBigSize() {
  33.         if ("{$this->size}" > 41) {
  34.             return true;
  35.         }
  36.     }
  37. }
  38.  
  39. $id1 = new TV();
  40. $id2 = new TV();
  41.  
  42. $id1->brand = 'Сони';
  43. $id2->brand = 'Филипс';
  44. $id1->size = 42;
  45. $id2->size = 40;
  46.  
  47.  
  48. //Шариковая ручка
  49.  
  50. class Pen
  51. {
  52.     public $color;
  53.     public $type;
  54.  
  55.     function getDescription() {
  56.         return "{$this->color} {$this->type}"; 
  57.     }
  58. }
  59.  
  60. $id1 = new Pen();
  61. $id2 = new Pen();
  62.  
  63. $id1->color = 'Черная';
  64. $id2->color = 'Синяя';
  65. $id1->type = 'Шариковая';
  66. $id2->type = 'Гелевая';
  67.  
  68. //Утка
  69.  
  70. class Duck
  71. {
  72.     public $name;
  73.     public $whereIs;
  74.  
  75.     function sayKryaKrya() {
  76.         return "{$this->name} сказал КРЯ-КРЯ"; 
  77.     }
  78. }
  79.  
  80. $id1 = new Duck();
  81. $id2 = new Duck();
  82.  
  83. $id1->name = 'Чёрный плащ';
  84. $id2->name = 'Скрудж МакДак';
  85. $id1->whereIs = 'На месте';
  86. $id2->whereIs = 'Зимует';
  87.  
  88. //Товар
  89.  
  90. class Item
  91. {
  92.     public $count;
  93.     public $available;
  94.  
  95.     function isAvailable() {
  96.         if ("{$this->available}" == true) {
  97.             return "В наличии {$this->count} шт.";
  98.         } else {
  99.             return "Товара нет в наличии";
  100.         }
  101.     }
  102. }
  103.  
  104. $id1 = new Item();
  105. $id2 = new Item();
  106.  
  107. $id1->count = 100;
  108. $id2->count = 200;
  109. $id1->available = true;
  110. $id2->available = false;
Advertisement
Add Comment
Please, Sign In to add comment