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...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

OBJECT 136Figura 15.3: Gerando o equals() no eclipse1 class Conta {2 private int numero ;3 private double saldo ;45 // método gerado pelo eclipse6 public int hashCo<strong>de</strong> () {7 final int prime = 31;8 int result = 1;9 result = prime * result + numero ;10 return result ;11 }1213 // método gerado pelo eclipse14 public boolean equals ( Object obj) {15 if ( this == obj ) {16 return true ;17 }18 if ( obj == null ) {19 return false ;20 }21 if (!( obj instanceof Conta )) {22 return false ;23 }24 Conta other = ( Conta ) obj ;25 if ( numero != other . numero ) {26 return false ;27 }28 return true ;29 }3031 // GETTERS E SETTERS32 }Código Java 15.17: Conta.javaExercícios <strong>de</strong> Fixação136 www.<strong>k19</strong>.com.br

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

Saved successfully!

Ooh no, something went wrong!