Advertisement
Lucasmateuseng

Codigo Erro

Jan 22nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php
  2.  
  3. //estrutura da classe
  4.  
  5. class Carro{
  6.  
  7.     private $modelo;
  8.     private $motor;
  9.     private $ano;
  10.  
  11.     //get, set $modelo
  12.     public function getModelo(){
  13.  
  14.         return $this->modelo;
  15.     }
  16.  
  17.     public function setModelo($modelo){
  18.  
  19.         $this->modelo = $modelo;
  20.  
  21.     }
  22.  
  23.     //get, set $motor
  24.     public function getMotor():float{
  25.  
  26.         return $this->motor;
  27.     }
  28.  
  29.     public function setMotor($motor){
  30.  
  31.         $this->modelo = $motor;
  32.  
  33.     }
  34.  
  35.     //get, set $ano
  36.     public function getAno():int{
  37.  
  38.         return $this->ano;
  39.     }
  40.  
  41.     public function setAno($ano){
  42.  
  43.         $this->modelo = $ano;
  44.  
  45.     }
  46.  
  47.     public function exibir(){
  48.  
  49.         return array(
  50.             "modelo"=>$this->getModelo(),
  51.             "motor"=>$this->getMotor(),
  52.             "ano"=>$this->getAno()
  53.         );
  54.  
  55.     }
  56.  
  57. }
  58.  
  59. $gol = new Carro();
  60. $gol->setModelo("gol GT");
  61. $gol->setMotor("1.6");
  62. $gol->setAno("2018");
  63.  
  64. var_dump ($gol->exibir());
  65.  
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement