earliest copyright date public Book getEarliest() // Mutator to examine bookToAdd, comparing its copyright date

write a class, EarliestBook. A series of books can be added to an EarliestBook object, but it remembers only the book with the earliest copyright date. EarliestBook should have the following constructor and methods: // constructor EarliestBook() // Accessor to return the book with the earliest copyright date public Book getEarliest() // Mutator to examine bookToAdd, comparing its copyright date with that of the current earliest book. // Only the book with the eariest date is remembered public void addBook(Book bookToAdd) nts: Think of the earliest book as “the earliest book that’s been added so far.” Books with later copyright dates are of no interest to an EarliestBook object. Also, pay attention to the first book (i.e., addBook being called for the first time). It will be “the earliest book added so far,” since it’s the only book added so far. Create and use an EarliestBook object from Bookshelf to record the oldest book created in that program. The Earl

💡 Buy the answer for only $12 Get it now →

iestBook class is a little confusing. What it is supposed to do is to wrap around a real Book object inside and update this internal Book object based on the copyright date. Something like this: public class EarliestBook { // the instance variable representing the book with the earliest copyright date private Book earliest = null; // constructor public EarliestBook() { } // accessor to return the book with the earliest copyright date public Book getEarliest() { return earliest; } // mutator to examine the bookToAdd, comparing its copyright date with that of the current earliest book public void addBook(Book bookToAdd) { if (earliest == null) { earliest = bookToAdd; } else { // Compare bookToAdd’s copyright date against earliest’s copyright date // update the earliest value accordingly. // You need to implement this section of the code // You might need to use some special techniques here. Example: http://www.mkyong.com/java/how-to-compare-dates-in-java/ } } }|

💡 Buy the answer for only $12 Get it now →