ph4x35ccb

Polimorfismo de sobrecarga

Apr 12th, 2019
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Sobrecarga</title>
  5. </head>
  6. <body>
  7.     <h1>
  8. <?php
  9. require_once 'Mamifero.php';
  10. require_once 'Lobo.php';
  11.  
  12. $c = new Lobo();
  13. $c->emitirSom();
  14. echo "<hr>";
  15.  
  16. ?>
  17.     </h1>
  18. </body>
  19. </html>
  20.  
  21. // classe Animal
  22. <?php
  23.  
  24. abstract class Animal{
  25.     protected $peso;
  26.     protected $idade;
  27.     protected $membros;
  28.     public abstract function emitirSom();
  29. }
  30.  
  31. // classe Mamifero
  32. <?php
  33. require_once 'Animal.php';
  34. class Mamifero extends Animal{
  35.    protected $corPelo;
  36.    public function emitirSom(){
  37.     echo "<p>Som mamifero</p>";
  38.    }
  39. }
  40.  
  41. // classe lobo
  42.  
  43. </<?php
  44. require_once 'Mamifero.php';
  45. class Lobo extends Mamifero{
  46.  
  47. }
  48.  
  49. //classe cachorro
  50.  
  51. <?php
  52.  
  53. require_once 'Lobo.php';
  54. class Cachorro extends Lobo{
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment