1 19 20 package org.bookmodule; 21 22 import java.io.Serializable ; 23 24 28 public class Book implements Serializable { 29 30 String author; 31 String title; 32 33 static final long serialVersionUID = -868500654892626305L; 34 35 public Book() { 36 author = "N/A"; 37 title = "N/A"; 38 } 39 40 public Book(String ar, String al) { 41 author = ar; 42 title = al; 43 } 44 45 public static Book createDefault() { 46 return new Book("Jesse, Tim & others", "NetBeans Definitive Guide"); 47 } 48 49 public boolean equals(Object o) { 50 if (!(o instanceof Book)) { 51 return false; 52 } 53 Book d = (Book)o; 54 return author.equals(d.author) && 55 title.equals(d.title); 56 } 57 58 public int hashCode() { 59 return 125; 61 } 62 63 public String toString() { 64 return "Book[author="+author+", title="+title+"]"+super.toString(); 65 } 66 67 } 68 | Popular Tags |