Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1.  
  2.  
  3. public class Livro {
  4.  
  5. private String titulo;
  6. private String autor;
  7. private int anoLancamento;
  8. private String isbn;
  9.  
  10. public Livro(String titulo, String autor, int anoLancamento, String isbn) {
  11. this.titulo = titulo;
  12. this.autor = autor;
  13. this.anoLancamento = anoLancamento;
  14. this.isbn = isbn;
  15. }
  16.  
  17. public String getTitulo() {
  18. return titulo;
  19. }
  20.  
  21. public void setTitulo(String titulo) {
  22. this.titulo = titulo;
  23. }
  24.  
  25. public String getAutor() {
  26. return autor;
  27. }
  28.  
  29. public void setAutor(String autor) {
  30. this.autor = autor;
  31. }
  32.  
  33. public int getAnoLancamento() {
  34. return anoLancamento;
  35. }
  36.  
  37. public void setAnoLancamento(int anoLancamento) {
  38. this.anoLancamento = anoLancamento;
  39. }
  40.  
  41. public String getIsbn() {
  42. return isbn;
  43. }
  44.  
  45.  
  46. public String toString(){
  47. return titulo + " (ISBN " + isbn + "), " + anoLancamento + "." + System.lineSeparator() + autor;
  48. }
  49.  
  50. @Override
  51. public int hashCode() {
  52. final int prime = 31;
  53. int result = 1;
  54. result = prime * result + ((isbn == null) ? 0 : isbn.hashCode());
  55. return result;
  56. }
  57.  
  58. @Override
  59. public boolean equals(Object obj) {
  60. if (this == obj)
  61. return true;
  62. if (obj == null)
  63. return false;
  64. if (getClass() != obj.getClass())
  65. return false;
  66. Livro other = (Livro) obj;
  67. if (isbn == null) {
  68. if (other.isbn != null)
  69. return false;
  70. } else if (!isbn.equals(other.isbn))
  71. return false;
  72. return true;
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement