HW1: Book Search

The 2-dim book array in the book list should be put in SearchBook.java. You won't get full credit if you put the array in Book.java
Book.java is supposed to be a standalone class, it shouldn't has any interaction with SearchBook.java

You can get some hints here.

In this homework you will write 2 classes Book and SearchBook
The class Book represent a book in real life, it contains the title and the author of the book.
It contains only 3 public methods and some public constructors.

boolean doesTitleContain(String word)
This method returns true if the title contains the word, otherwise return 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") return 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() return String ! Don't use System.out.println(...)

In the class SearchBook, it has a main function so that
java SearchBook Charles
gives all the books whose title or author contains the word "Charles".
The list of books is found in booklist.

Submit your work (Book.java, SearchBook.java ) to submit folder.
So in your submit folder you should have
Book.java
, SearchBook.java



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

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

C:\hw1>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:\hw1>java SearchBook xyz
We were unable to find exact matches for your search for xyz .

C:\hw1>java SearchBook
Usage : java SearchBook word
Search books match the word.

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

New information:





Start you file  with
\\  name  :  your name
\\  student id   : your student id   

and

If you think this homework is too easy,  try challenge here,  but you won't get any extra credits for it.

Solution

Book.java , SearchBook.java