Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Funcionario{
  2.  
  3.     public $nome;
  4.     protected $endereco;
  5.     protected $salario;
  6.     protected $bonificacao;
  7.  
  8.     function __construct() {
  9.         $this->bonificacao = 100;
  10.     }
  11.  
  12.     function setSalario($salario){
  13.         $this->salario = $salario;
  14.     }
  15.  
  16.     function getSalario(){
  17.         return $this->salario + $this->bonificacao;
  18.     }
  19.  
  20.     function setEndereco($endereco){
  21.         $this->endereco = $endereco;
  22.     }
  23.     function getEndereco(){
  24.         return $this->endereco;
  25.     }
  26. }
  27. $func1 = new Funcionario();
  28. $func1->nome = "Cicrano Lima";
  29. $func1->setEndereco("Rua D");
  30. $func1->setSalario(1000);
  31. echo "<h2>Dados Funcionarios</h2>";
  32. echo "Nome Funcionario: ".$func1->nome."<br/>";
  33. echo "Endereco Funcionario: ".$func1->getEndereco();
  34. echo "Salario: ".$func1->getSalario();
  35.  
  36. class Estagiario extends Funcionario{
  37.     protected $participacao;
  38.     function __construct(){
  39.         parent::__construct();
  40.         $this->participacao = 0.2;
  41.     }
  42.  
  43.     function getSalario() {
  44.         return parent::getSalario() + (parent::getSalario() * $this->participacao);
  45.     }
  46. }
  47. $estag1 = new Estagiario();
  48. $estag1->nome = "Fulano Sousa";
  49. $estag1->setEndereco("Rua Cinco");
  50. $estag1->setSalario(1500);
  51. echo "<h2>Dados Estagiarios</h2>";
  52. echo "Nome Estagiario: ".$estag1->nome."<br/>";
  53. echo "Endereco Estagiario: ".$estag1->getEndereco();
  54. echo "Salario: ".$estag1->getSalario();
  55.  
  56. class FuncionarioLimpeza extends Funcionario{
  57.  
  58.     public $cargo;
  59. }
  60. $funLimp = new FuncionarioLimpeza();
  61. $funLimp->nome = "Beltrano Marques";
  62. $funLimp->setEndereco("Rua Tres");
  63. $funLimp->cargo = "Limpa Moveis";
  64. echo "<h2>Dados Funcionarios da Limpeza</h2>";
  65. echo "Nome Func Limp: ".$funLimp->nome."<br/>";
  66. echo "Endereco: ".$funLimp->getEndereco()."<br/>";
  67. echo "Cargo: ".$funLimp->cargo;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement