Skip to content
Snippets Groups Projects
Commit 76affa1e authored by Jiawei Wang's avatar Jiawei Wang
Browse files

initial commit

parents
No related branches found
No related tags found
No related merge requests found
.settings/
.classpath
.project
*.class
*.java~
/bin
\ No newline at end of file
public class Book {
private String name;
private String author;
private int pages;
private int publicationYear;
private String ISBN;
public Book(String name, String author, int pages, int publicationYear, String iSBN) {
super();
this.name = name;
this.author = author;
this.pages = pages;
this.publicationYear = publicationYear;
ISBN = iSBN;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public int getPages() {
return pages;
}
public void setPages(int pages) {
this.pages = pages;
}
public int getPublicationYear() {
return publicationYear;
}
public void setPublicationYear(int publicationYear) {
this.publicationYear = publicationYear;
}
public String getISBN() {
return ISBN;
}
public void setISBN(String iSBN) {
ISBN = iSBN;
}
@Override
public String toString() {
return "Book [name=" + name + ", author=" + author + ", pages=" + pages + ", publicationYear=" + publicationYear
+ ", ISBN=" + ISBN + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((ISBN == null) ? 0 : ISBN.hashCode());
result = prime * result + ((author == null) ? 0 : author.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + pages;
result = prime * result + publicationYear;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Book other = (Book) obj;
if (ISBN == null) {
if (other.ISBN != null)
return false;
} else if (!ISBN.equals(other.ISBN))
return false;
if (author == null) {
if (other.author != null)
return false;
} else if (!author.equals(other.author))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (pages != other.pages)
return false;
if (publicationYear != other.publicationYear)
return false;
return true;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment