Question: Using the PublishedWork class provided below as the base class, design a public subclass named Book which inherits from the PublishedWork class and meets the



Using the PublishedWork class provided below as the base class, design a public subclass named Book which inherits from the PublishedWork class and meets the following specifications:

The derived Book class must include instance fields for the number of pages as an integer and a book ttype using the enum provided here: enum BookType{ NOTYPE, PAPERBACK, HARDBACK, EBOOK, AUDIO };

The derived Book class must provide a default constructor and an overloaded constructor. The overloaded constructor must accept four arguments: title, author, number of pages, and book ttype (using the enum definition provided above).

The derived Book class must provide mutators and accessors for all of its own fields only, do not provide these methods for inherited fields. The Book class must provide a toString() method which, when printed, will display a one-line String value similar to the Sample Output shown here (the enclosing quotes for the title and comma separators are required):

Sample Output Book: "Living Dangerously", author: Smith, pages: 500, type: PAPERBACK

Hint: the name() method of an enumerated ttype will return the String version of an enum type's name.

The Book class must include an equals method which determines equality based on the book's title and author only; the number of pages and book ttype are not used to determine equality. For example, the following two books are considered to be equal: Book: "Living Dangerously", author: Smith, pages: 500, type: PAPERBACK Book: "Living Dangerously", author: Smith, pages: 550, type: HARDBACK

The PublishedWork base class is specified here:

// PublishedWork.java // I. Am // 1/1/1991 // represents a published work

public class PublishedWork { private String title; private String author;

// default constructor public PublishedWork() { this.title = "no title"; this.author = "no name"; } // overloaded constructor public PublishedWork(String title, String author) { this.title = title; this.author = author; } // accessors public String getTitle() { return title; } public String getAuthor() { return author; } }

Your solution should include only the derived Book class. Do not include a main method, Do not include the PublishedWork base class in your solution, "this" must be used whenever name contention occurs (e.g. constructors and mutators). Use of "this" in other components is allowed, but not required. An ID header for your source code must be provided.

Step by Step Solution

3.50 Rating (147 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Bookjava I Am 111991 represents a book import javautilObjects public class Book extends PublishedWor... View full answer

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!