Question: Create a class named Poem that contains fields for the name of the poem and the number of lines in it. Include a constructor that
Create a class named Poem that contains fields for the name of the poem and the number of lines in it. Include a constructor that requires values for both fields. Also include get methods to retrieve field values. Create three subclasses: Couplet, Limerick, and Haiku. The constructor for each subclass requires only a title; the lines field is set using a constant value. A couplet has two lines, a limerick has five lines, and a haiku has three lines. Create an application that demonstrates usage of an object of each type. Save the files as Poem.java, Couplet.java, Limerick.java, Haiku.java, and DemoPoems.java.
Step by Step Solution
3.42 Rating (155 Votes )
There are 3 Steps involved in it
public class Poem private String title private int lines public PoemString name int numLines title n... View full answer
Get step-by-step solutions from verified subject matter experts
