12.07.2015 Views

k19-k11-orientacao-a.. - Departamento de Sistemas e Computação

k19-k11-orientacao-a.. - Departamento de Sistemas e Computação

k19-k11-orientacao-a.. - Departamento de Sistemas e Computação

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

HERANÇA 924 g. setNome (" Rafael Cosentino ");5 g. setSalario (2000) ;6 g. setUsuario (" rafael . cosentino ");7 g. setSenha (" 12345 ");89 Telefonista t = new Telefonista ();10 t. setNome (" Carolina Mello ");11 t. setSalario (1000) ;12 t. setEstacaoDeTrabalho (13) ;1314 Secretaria s = new Secretaria ();15 s. setNome (" Tatiane Andra<strong>de</strong> ");16 s. setSalario (1500) ;17 s. setRamal (198) ;1819 System . out . println (" GERENTE ");20 System . out . println (" Nome : " + g. getNome ());21 System . out . println (" Salário : " + g. getSalario ());22 System . out . println (" Usuário : " + g. getUsuario ());23 System . out . println (" Senha : " + g. getSenha ());24 System . out . println (" Bonificação : " + g. calculaBonificacao ());2526 System . out . println (" TELEFONISTA ");27 System . out . println (" Nome : " + t. getNome ());28 System . out . println (" Salário : " + t. getSalario ());29 System . out . println (" Estacao <strong>de</strong> trabalho : " + t. getEstacaoDeTrabalho ());30 System . out . println (" Bonificação : " + t. calculaBonificacao ());3132 System . out . println (" SECRETARIA ");33 System . out . println (" Nome : " + s. getNome ());34 System . out . println (" Salário : " + s. getSalario ());35 System . out . println (" Ramal : " + s. getRamal ());36 System . out . println (" Bonificação : " + s. calculaBonificacao ());37 }38 }Código Java 8.26: TestaFuncionarios.java7 Suponha que os gerentes recebam uma bonificação maior que os outros funcionários. Reescrevao método calculaBonificacao() na classe Gerente. Depois, compile e execute o teste novamente.1 class Gerente extends Funcionario {2 private String usuario ;3 private String senha ;45 public double calculaBonificacao () {6 return this . getSalario () * 0.6 + 100;7 }89 // GETTERS AND SETTERS10 }Código Java 8.27: Gerente.javaExercícios Complementares1 Defina na classe Funcionario um método para imprimir na tela o nome, salário e bonificaçãodos funcionários.2 Reescreva o método que imprime os dados dos funcionários nas classes Gerente, Telefonistae Secretaria para acrescentar a impressão dos dados específicos <strong>de</strong> cada tipo <strong>de</strong> funcionário.3 Modifique a classe TestaFuncionario para utilizar o método mostraDados().92 www.<strong>k19</strong>.com.br

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!