Question: Write this code in java language. Do not use arraylist when creating arrays. 1 . Implement a Book class which has the following members: Three

Write this code in java language. Do not use arraylist when creating arrays.
1. Implement a Book class which has the following members:
Three Private member variables: title (String), releaseYear (int), isNew (Boolean)
Public methods: two constructors: one no-argument constructor and one overloaded constructor which takes three parameters in the following order: String, Boolean, int
2. Implement a Bookshelf collection class. This is a collection of objects from the Book class. It has the following members:
two private member variables: bookArray (Book), numItems(int)
a constructor that takes an integer as parameter to initialize the size of the array bookArray
3. Assuming that the bookshelf list is unordered, write an insert() method for the Bookshelf class. This is a void method that takes a Book object as parameter.
4. Create a driver class named BookshelfDriver.
5. Declare an object of type Bookshelf inside the driver class named myLibrary and add the following two book to mylibrary:
Book 1: How to Catch a Dinosaur,2019, isNew=true
Book 2: I am Enough,2018, isNew=true
6. Add two additional books of your choice
7. In your Book class, create a toString() method that returns the values of the private member variables separated by a tab.
8. In the Bookshelf class, create a toString() method. This should return a string that includes the header Current Book List followed by the information about all the books in the array on the subsequent lines (you will need to call the toString() method of the Book class).
9. In the Bookshelf class, update the insert() method to make sure the book collection stays organized. We want the books to be listed from newest to oldest. Therefore, when adding a new book, we must compare the releaseYear of the new book with the releaseYear of existing books and insert it in the correct spot to maintain the sorted order. This way, whenever you look at the collection, you'll see the latest releases first in the array. Feel free to use or not use a helper method.
10. Create a void method called remove() in the Bookshelf class. This method takes one input parameter of type Book. The method then searches the collection for the first object that equals the input object and deletes its occurrence if found. After the item has been deleted, the list must still be maintained in order.
11. Test it in the driver class to make sure that it maintains the order of the collection.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!