Advertisement
ph4x35ccb

Aula 14b POO Gustavo quanabara

Apr 13th, 2019
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.35 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title></title>
  5. </head>
  6. <body>
  7.     <?php
  8.         require_once 'Video.php';
  9.         require_once 'Gafanhoto.php';
  10.         $v[0]= new Video("Aula 1 POO");
  11.         $v[2]= new Video("Aula 12 PHP");
  12.         $v[3]= new Video("Aula 15 HTML5");
  13.  
  14.         $g = new Gafanhoto("Jubileu",30,"M","Juba");
  15.        
  16.         echo "<pre>";
  17.         print_r($v);
  18.         echo "<br>";
  19.         print_r($g)
  20.     ?>
  21. </body>
  22. </html>
  23. //classe açoes video
  24. <?php
  25. interface AcoesVideo{
  26.     public function play();
  27.     public function pause();
  28.     public function like();
  29. }
  30. //classe Video
  31. <?php
  32. require_once 'AcoesVideo.php';
  33. class Video implements AcoesVideo {
  34.     private $titulo;
  35.     private $avaliacao;
  36.     private $views;
  37.     private $curtidas;
  38.     private $reproduzindo;
  39.  
  40.     public function __construct($titulo){
  41.         $this->titulo=$titulo;
  42.         $this->avaliacao=1;
  43.         $this->views=0;
  44.         $this->curtidas=0;
  45.         $this->reproduzindo=false;
  46.     }
  47.  
  48.     public function getTitulo(){
  49.         return $this->titulo;
  50.     }
  51.     public function setTitulo($titulo){
  52.         $this->titulo=$titulo;
  53.     }
  54.     public function getAvaliacao(){
  55.         return $this->avaliacao;
  56.     }
  57.     public function setAvaliacao($avaliacao){
  58.         $this->avaliacao=$avaliacao;
  59.     }
  60.     public function getViews(){
  61.         return $this->views;
  62.     }
  63.     public function setViews($views){
  64.         $this->views=$views;
  65.     }
  66.     public function getCurtidas(){
  67.         return $this->curtidas;
  68.     }
  69.     public function setCurtidas(){
  70.         $this->curtidas=$curtidas;
  71.     }
  72.     public function getReproduzindo(){
  73.         return $this->reproduzindo;
  74.     }
  75.     public function setReproduzindo(){
  76.         $this->reproduzindo=$reproduzindo;
  77.     }
  78.     public function play(){
  79.         $this->reproduzindo=true;
  80.     }
  81.     public function pause(){
  82.         $this->reproduzindo=false;
  83.     }
  84.     public function like(){
  85.         $this->curtidas+=1;
  86.     }
  87. }
  88. // classe Pessoa abstrata
  89. <?php
  90. abstract class Pessoa{
  91.     protected $nome;
  92.     protected $idade;
  93.     protected $sexo;
  94.     protected $experiencia;
  95.  
  96.     public function __construct($nome, $idade, $sexo){
  97.         $this->nome = $nome;
  98.         $this->idade= $idade;
  99.         $this->sexo= $sexo;
  100.         $this->experiencia += 1;
  101.     }
  102.  
  103.     protected function ganharexp($n){
  104.         $this->expreriencia += $n;
  105.     }
  106.  
  107.     public function getNome(){
  108.         return $this->nome;
  109.     }
  110.     public function setNome($nome){
  111.         $this->nome=$nome;
  112.     }
  113.     public function getIdade(){
  114.         return $this->idade;
  115.     }
  116.     public function setIdade($idade){
  117.         $this->idade=$idade;
  118.     }
  119.     public function getSexo(){
  120.         return $this->sexo;
  121.     }
  122.     public function setSexo($sexo){
  123.         $this->sexo=$sexo;
  124.     }
  125.     public function getExperiencia(){
  126.         return $this->experiencia;
  127.     }
  128.     public function setExperiencia($experiencia){
  129.         $this->experiencia=$experiencia;
  130.     }
  131.  
  132. }
  133. //classe gafanhoto
  134. <?php
  135. require_once 'Pessoa.php';
  136. class Gafanhoto extends Pessoa{
  137.     private $login;
  138.     private $totAssirtido;
  139.    
  140.     public function __construct($nome,$idade,$sexo,$login){
  141.         parent::__construct($nome,$idade,$sexo);
  142.         $this->login=$login;
  143.         $this->totAssirtido=0;
  144.     }
  145.     public function assirtirMaisUm(){
  146.         $this->totAssirtido++;
  147.     }
  148.     public function getLogin(){
  149.         return $this->login;
  150.     }
  151.     public function setLogin(){
  152.         $this->login=$login;
  153.     }
  154.     public function getTotAssirtido(){
  155.         return $this->totAssirtido;
  156.     }
  157.     public function setTotAssirtido($totAssirtido){
  158.         $this->totAssirtido=$totAssirtido;
  159.     }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement