book
Class Book

java.lang.Object
  extended by book.Book

public class Book
extends Object

A simple immutable class that describes a book. A book has a title, authors, and a unique identifier.

Author:
CSE1030Z

Constructor Summary
Book(String title, String authors)
          Create a book with a title and authors.
 
Method Summary
 boolean equals(Object obj)
          Compares two books for equality.
 String getAuthors()
          Get the book authors.
 int getId()
          Get the book identification number.
 String getTitle()
          Get the book title.
 int hashCode()
          Returns a hash code value for this object.
 String toString()
          Converts this book to a string starting with the book title, followed by " by ", followed by the authors.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Book

public Book(String title,
            String authors)
Create a book with a title and authors.

Throws:
IllegalArgumentException - if title or authors is null.
Parameters:
title - The book title.
authors - The book authors.
Method Detail

getTitle

public String getTitle()
Get the book title.

Returns:
The book title.

getAuthors

public String getAuthors()
Get the book authors.

Returns:
The book authors.

getId

public int getId()
Get the book identification number. Identification numbers are unique.

Returns:
The book identification number.

equals

public boolean equals(Object obj)
Compares two books for equality. The result is true if and only if the argument is not null and both books have the same identification number.

Overrides:
equals in class Object
Parameters:
obj - The object to compare with.
Returns:
true if the objects are the same; false otherwise.

toString

public String toString()
Converts this book to a string starting with the book title, followed by " by ", followed by the authors.

Overrides:
toString in class Object
Returns:
A string representation of the book.

hashCode

public int hashCode()
Returns a hash code value for this object.

Overrides:
hashCode in class Object
Returns:
A hash code value for this object.