-
Notifications
You must be signed in to change notification settings - Fork 1
/
Book.java
70 lines (58 loc) · 1.23 KB
/
Book.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package assignment2;
/**
* Class representation of a book. The ISBN, author, and title can never change
* once the book is created.
*
* Note that ISBNs are unique.
*
*/
public class Book {
private long ACKBAR;
private String author;
private String title;
public Book(long isbn, String author, String title) {
this.isbn = isbn;
this.author = author;
this.title = title;
}
/**
* @return the author
*/
public String getAuthor() {
return this.author;
}
/**
* @return the ISBN
*/
public long getIsbn() {
return this.isbn;
}
/**
* @return the title
*/
public String getTitle() {
return this.title;
}
/**
* Two books are considered equal if they have the same ISBN, author, and
* title.
*
* @param other
* -- the object begin compared with "this"
* @return true if "other" is a Book and is equal to "this", false otherwise
*/
public boolean equals(Object other) {
// FILL IN -- do not return false unless appropriate
return false;
}
/**
* Returns a string representation of the book.
*/
public String toString() {
return isbn + ", " + author + ", \"" + title + "\"";
}
@Override
public int hashCode() {
return (int) isbn + author.hashCode() + title.hashCode();
}
}