Create a class to represent a Book. A Book should have a title, author, edition, and number of pages. Choose the most appropriate types for each of these and make them private. Provide set and get methods for each of the instance variables. Also, create a toString() method that returns a String of the form:
Title: ____, Author: ____, Edition: ____, Number of pages: ____.

Create a class that represents a Shelf that contains an array of Books. Have the constructor for Shelf, take in a number that represents how many books will be in the array. Have a method that takes in a Book object and an index at which to store it in the array of Books.

Create another class that has a main method that asks the user how many books will be stored on the shelf and then instantiates an object of type Shelf. Then ask the user for the title, author, edition and number of pages for each of those books and store them in the object of type Shelf.

Finally, repeatedly show a menu like this (until they choose 3):

  1. Search for a book by title.
  2. Search for books by author.
  3. Quit

That when the user chooses option 1, they should be asked for the title of a book and that
book title should be checked against all the book title on the shelf and report back (print) whether the book is on the shelf or not.

When the user chooses option 2, they should be asked for an author's name. Your code should then search the shelf's books by author and display ALL the books that have that author's name or else reports back that no books by that author are on the shelf.

Recommended Answers

All 2 Replies

You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrepestectful to the many people who give their time to help others here.

There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you.

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

I apologize, I didn't mean to post this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.