bizzcuit

Book

Sep 25th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. package com.rewe.exercise.bookstore.book;
  2.  
  3. import com.rewe.exercise.bookstore.author.Author;
  4.  
  5. import java.util.ArrayList;
  6. import java.util.List;
  7. import java.util.Objects;
  8.  
  9. public class Book {
  10.  
  11. private Long isbn;
  12.  
  13. private String title;
  14.  
  15. private String publisher;
  16.  
  17. private int year;
  18.  
  19. private double price;
  20.  
  21. private int availableQuantity;
  22.  
  23. private List<Author> authors = new ArrayList<>();
  24.  
  25. public Long getIsbn() {
  26. return isbn;
  27. }
  28.  
  29. void setIsbn(Long isbn) {
  30. this.isbn = isbn;
  31. }
  32.  
  33. public String getTitle() {
  34. return title;
  35. }
  36.  
  37. void setTitle(String title) {
  38. this.title = title;
  39. }
  40.  
  41. public String getPublisher() {
  42. return publisher;
  43. }
  44.  
  45. void setPublisher(String publisher) {
  46. this.publisher = publisher;
  47. }
  48.  
  49. public int getYear() {
  50. return year;
  51. }
  52.  
  53. void setYear(int year) {
  54. this.year = year;
  55. }
  56.  
  57. public double getPrice() {
  58. return price;
  59. }
  60.  
  61. void setPrice(double price) {
  62. this.price = price;
  63. }
  64.  
  65. public int getAvailableQuantity() {
  66. return availableQuantity;
  67. }
  68.  
  69. void setAvailableQuantity(int quantity) {
  70. availableQuantity = quantity;
  71. }
  72.  
  73. List<Author> getAuthors() {
  74. return authors;
  75. }
  76.  
  77. void setAuthors(List<Author> authors) {
  78. this.authors = authors;
  79. }
  80.  
  81. @Override
  82. public boolean equals(Object o) {
  83. if (this == o) return true;
  84. if (o == null || getClass() != o.getClass()) return false;
  85. Book book = (Book) o;
  86. return year == book.year &&
  87. Double.compare(book.price, price) == 0 &&
  88. Objects.equals(title, book.title) &&
  89. Objects.equals(publisher, book.publisher);
  90. }
  91.  
  92. @Override
  93. public int hashCode() {
  94. return Objects.hash(title, publisher, year, price);
  95. }
  96.  
  97. @Override
  98. public String toString() {
  99. return "Book{" +
  100. ", title='" + title + '\'' +
  101. ", publisher='" + publisher + '\'' +
  102. ", year=" + year +
  103. ", price=" + price +
  104. '}';
  105. }
  106. }
Add Comment
Please, Sign In to add comment