This assignment is designed to introduce you to arrays as well as reinforce your understanding of Exceptions, loops, and Java, in general.
It asks you to build a Bookshelf class capable of holding a fixed number of books. The Bookshelf has a few simple behaviors, which are described below. It also asks you to developa Menu class which should contain the main() method and provide the user with a menu allowing the user to exercise all of the features of the Bookshelf class.
Each Bookshelf should allow the user to store a fixed number of books. The user can add, remove, and access books as described below.
- The constructor should take a single parameter, the maximumNumberOfBooks that the Bookshelf can hold.
- Users should be able to addABook() at a book at a particular position. This should place a book at the specified position, losing any book which might have previously resided at the specified position.
- Users should be able to getABook() by specifying the book's position. If no book is located at the specified position, the Bookshelf.TextbookNotFoundException should be thrown. Yes, this does imply that you'll need to create the TextbookNotFoundException nested within the Bookshelf class.
- Users should be able to removeABook() by specifying the index of the book to remove.
- The user should be able to getAList() which should provide a nicely formatted String containing the titles of each Textbook. This listing should list only actual textbooks, not null references.
- If ever the user specifies an index that is not valid, the IndexOutOfBoundsException should be thrown.
The Menu class
The menu should provide the user with the option of creating a new Bookshelf of a user-defined size, and then of adding, removing, and printing indididual books, or of printing a list of the titles of all books wihtin the Bookshelf.
The Textbook class
You may use your prior Textbook class, or the Textbook.java that we provide.