Guest User

Untitled

a guest
Feb 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. <?php
  2. define(U1, 10);
  3.  
  4. class Machine {
  5. public $name;
  6. public $model;
  7. public $price;
  8. public $maxpassagers;
  9.  
  10. public function setName($name) {
  11. $this->name = $name;
  12. }
  13.  
  14. public function getName() {
  15. return $this->name;
  16. }
  17.  
  18. public function setModel($model) {
  19. $this->model = $model;
  20. }
  21.  
  22. public function getModel() {
  23. return $this->model;
  24. }
  25.  
  26. public function setPrice($price) {
  27. $this->price = $price;
  28. }
  29.  
  30. public function getPrice() {
  31. return $this->price;
  32. }
  33.  
  34. public function setMaxpassagers($maxpassagers) {
  35. $this->maxpassagers = $maxpassagers;
  36. }
  37.  
  38. public function getMaxpassagers() {
  39. return $this->maxpassagers;
  40. }
  41. }
  42. class Cars extends Machine {
  43.  
  44. }
  45.  
  46. class Bus extends Machine {
  47.  
  48. }
  49.  
  50. class Moto extends Machine {
  51.  
  52. }
  53.  
  54. $product3 = new Bus();
  55. $product3->setName('Honda');
  56. $product3->setModel('Giorno');
  57. $product3->setPrice(5);
  58. $product3->setMaxpassagers(1);
  59.  
  60. $product4 = new Cars();
  61. $product4->setName('WV');
  62. $product4->setModel('B5');
  63. $product4->setPrice(12);
  64. $product4->setMaxpassagers(4);
  65.  
  66. if( ( $product3->getPrice() ) <= U1) {
  67. $need = U1 - $product3->getPrice();
  68. echo
  69. '<h4><b>'.$product3->getName().'</b> is good for you.';
  70. if ($need > 0)
  71. echo ' You save: <b>'.$need.'$</b><br></h4>';
  72. }
  73. else{
  74. $need = $product3->getPrice() - U1;
  75. echo '<b>'.$product3->getName().'</b> is bad for you. You need <b>'.$need.'$</b><br>';
  76. }
  77.  
  78. if( ( $product4->getPrice() ) <= U1) {
  79. $need = U1 - $product4->getPrice();
  80. echo
  81. '<h4><b>'.$product4->getName().'</b> is good for you.';
  82. if ($need > 0)
  83. echo ' You save: <b>'.$need.'$</b><br></h4>';
  84. }
  85. else{
  86. $need = $product4->getPrice() - U1;
  87. echo '<b>'.$product4->getName().'</b> is bad for you. You need <b>'.$need.'$</b><br>';
  88. }
  89. ?>
Add Comment
Please, Sign In to add comment