Question: Attached is an abstract class named ArtisticWork. Create two new classes named Poem and Book which inherit from ArtisticWork Poem should have additional attribute of

Attached is an abstract class named ArtisticWork. Create two new classes named Poem and Book which inherit from ArtisticWork Poem should have additional attribute of numberOfStanzas (int) and Book should have the additional attribute of numerOfPages (int). In addition, both Poem and Book should implement the Comparable interface. Two books or poems are equal if all attributes are the same. Otherwise, a book or poem is less than the other book or poem if its name is alphabetically less than the other book. It is greater than, if its name is alphabetically greater than the other book or poem.

ArtisticWork.Java /** * Abstract Parent class for artistic works * * */ public abstract class ArtisticWork { protected String name; protected String creator;

/** * @param name * @param creator */ public ArtisticWork(String name, String creator) {

this.name = name; this.creator = creator; }

/** * no arg constructor */ public ArtisticWork() { this.name = \"unknown\"; this.creator = \"unknown\"; }

/** * @return the name */ public String getName() { return name; }

/** * @param name the name to set */ public void setName(String name) { this.name = name; }

/** * @return the creator */ public String getCreator() { return creator; }

/** * @param creator the creator to set */ public void setCreator(String creator) { this.creator = creator; }

@Override public String toString() { return \"ArtisticWork [name=\" + name + \", creator=\" + creator + \"]\"; }

}

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!