HW 2: Book Search

In this homework you will write 2 classes: Book and SearchBook
The class Book represents a book in real life; it contains the title and the author of the book.
It contains only 3 public methods and one or morepublic constructor(s).

boolean doesTitleContain(String word)
This method returns true if the title contains the word, otherwise returns false.  The method is not case sensitive. i.e.
we don't distinguish between  words like "abc" and "ABC".
Example if the book is Java Notes written by Charles Li.
then  doesTitleContain("java") returns true because Java Notes  contains the word "java".
doesTitleContain("no") also returns true  because the title Java Notes contains the word. "no"

boolean doesAuthorContain(String word)
This method returns true it the author contains the word, otherwise returns false. The method is not case sensitive. i.e.
we don't distinguish between  words like "abc" and "ABC"
Example if the book is Java Notes written by Charles Li.
then doesAuthorContain("le") returns true (Charles Li).
doesAuthorContain("charles") also returns true.

String showInfo()

Show information about the book. For example if the book is   Java Notes by Charles Li, the showInfo() returns a string like this
Title : Java Notes
Author : Charles Li
showInfo() returns a String ! Don't use System.out.println(...)

The class SearchBook has a main function which makes
java SearchBook Charles
give all the books whose title or author contains the word "Charles". The list of books is found in booklist.


Here are some outputs of the program
C:\hw2> java SearchBook bean
1.
Title: Enterprise JavaBeans
Author: Richard Monson-Haefel

2.
Title: Mr. Bean's Diary
Author: Robin Driscoll, Rowan Atkinson

C:\hw2>java SearchBook hack
1.
Title: Hacking Linux Exposed
Author: Brian Hatch

2.
Title: Hack Attacks Encyclopedia: A Complete History of Hacks, Cracks, Phreaks, and Spies over Time
Author: John Chirillo

3.
Title: Hack Attacks Denied: Complete Guide to Network LockDown
Author: John Chirillo

4.
Title: Hack Proofing Your Web Applications
Author: Julie Traxler

C:\hw2>java SearchBook xyz
We were unable to find exact matches for your search for xyz .

C:\hw2>java SearchBook
Usage : java SearchBook word
Searches books for matches to word.

We only care about the first argument and ignore all other arguments. so
java SearchBook bean is same as java SearchBook bean Charles

More information:

Hint

You can get some hints here.

What to submit

Call your source code file Book.java, SearchBook.java. Put these files in your submit folder. Do not place this file inside another folder within your submit folder.

Remark

Solution

Book.java, SearchBook.java.