Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the necessary fields, classes, implement all methods #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions src/main/java/com/epam/izh/rd/online/entity/Author.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,73 @@
* 6) Переопределить метод toString с выводом всех полей (не забывайте alt+inset)
*/
public class Author {
private String name;
private String lastName;
private LocalDate birthdate;
private String country;

public Author() {
}

public Author(String name, String lastName, LocalDate birthdate, String country) {
this.name = name;
this.lastName = lastName;
this.birthdate = birthdate;
this.country = country;
}

public void setName(String name) {
this.name = name;
}

public String getName() {
return name;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getLastName() {
return lastName;
}

public void setBirthdate(LocalDate birthdate) {
this.birthdate = birthdate;
}

public LocalDate getBirthdate() {
return birthdate;
}

public void setCountry(String country) {
this.country = country;
}

public String getCountry() {
return country;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Author)) return false;
Author author = (Author) o;
return Objects.equals(getName(), author.getName()) && Objects.equals(getLastName(), author.getLastName()) && Objects.equals(getBirthdate(), author.getBirthdate()) && Objects.equals(getCountry(), author.getCountry());
}

@Override
public int hashCode() {
return Objects.hash(getName(), getLastName(), getBirthdate(), getCountry());
}

@Override
public String toString() {
return "Author{" +
"name='" + name + '\'' +
", lastName='" + lastName + '\'' +
", birthDate=" + birthdate +
", country='" + country + '\'' +
'}';
}
}
47 changes: 47 additions & 0 deletions src/main/java/com/epam/izh/rd/online/entity/Book.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,51 @@
*/
public abstract class Book {

private int numberOfPages;
private String name;

public Book() {
}

public Book(int numberOfPages, String name) {
this.numberOfPages = numberOfPages;
this.name = name;
}

public void setNumberOfPages(int numberOfPages) {
this.numberOfPages = numberOfPages;
}

public int getNumberOfPages() {
return numberOfPages;
}

public void setName(String name) {
this.name = name;
}

public String getName() {
return name;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Book)) return false;
Book book = (Book) o;
return getNumberOfPages() == book.getNumberOfPages() && Objects.equals(getName(), book.getName());
}

@Override
public int hashCode() {
return Objects.hash(getNumberOfPages(), getName());
}

@Override
public String toString() {
return "Book{" +
"numberOfPages=" + numberOfPages +
", name='" + name + '\'' +
'}';
}
}
59 changes: 59 additions & 0 deletions src/main/java/com/epam/izh/rd/online/entity/SchoolBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,64 @@
* 6) Переопределить метод toString с выводом всех полей (не забывайте alt+inset)
*/
public class SchoolBook extends Book {
private String authorName;
private String authorLastName;
private LocalDate publishDate;

public SchoolBook() {
}

public SchoolBook(int numberOfPages, String name, String authorName, String authorLastName, LocalDate publishDate) {
super(numberOfPages, name);
this.authorName = authorName;
this.authorLastName = authorLastName;
this.publishDate = publishDate;
}

public void setAuthorName(String authorName) {
this.authorName = authorName;
}

public String getAuthorName() {
return authorName;
}

public void setAuthorLastName(String authorLastName) {
this.authorLastName = authorLastName;
}

public String getAuthorLastName() {
return authorLastName;
}

public void setPublishDate(LocalDate publishDate) {
this.publishDate = publishDate;
}

public LocalDate getPublishDate() {
return publishDate;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SchoolBook)) return false;
if (!super.equals(o)) return false;
SchoolBook that = (SchoolBook) o;
return getAuthorName().equals(that.getAuthorName()) && getAuthorLastName().equals(that.getAuthorLastName()) && getPublishDate().equals(that.getPublishDate());
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), getAuthorName(), getAuthorLastName(), getPublishDate());
}

@Override
public String toString() {
return "SchoolBook{" +
"authorName='" + authorName + '\'' +
", authorLastName='" + authorLastName + '\'' +
", publishDate=" + publishDate +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ public interface AuthorRepository {
*/
int count();
}