1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Rudiy27
3 years ago
14

Create a class named Poem that contains the following fields: title - the name of the poem (of type String) lines - the number o

f lines in the poem (of type int) 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.
Please correct so code works:

Couplet.java

public class Couplet
{
private final static int LINES = 2;
public Couplet(String poemName)
{
super(poemName, LINES);
}
}

Haiku.java

public class Haiku extends Poem
{
private static int LINES = 3;
public Haiku(String poemName)
{
super(poemName, LINES);
}
}

Limerick.java

public class Limerick
{
private static int LINES = 5;
public Limerick(String poemName)
{
super(poemName, LINES);
}
}

Poem.java

public class Poem
{
private String poemName;
private int lines;

public Poem(String poemName, int lines)
{
this.poemName = poemName;
this.lines = lines;
}

public String getPoemName()
{
return poemName;
}

public int getLines()
{
return lines;
}
}

DemoPoem.java

import java.util.*;
public class DemoPoems
{
public static void main(String[] args)
{
Poem poem1 = new Poem("The Raven", 84);
Couplet poem2 = new Couplet("True Wit");
Limerick poem3 = new Limerick("There was an Old Man with a Beard");
Haiku poem4 = new Haiku("The Wren");
display(poem1);
display(poem2);
display(poem3);
display(poem4);
}

public static void display(Poem p)
{
System.out.println("Poem: " + p.getTitle() +
" Lines: " + p.getLines());
}
}
Computers and Technology
1 answer:
denpristay [2]3 years ago
7 0

Answer:

Couplet.java



public class Couplet extends Poem

{

private final static int LINES = 2;

public Couplet(String poemName)

{

super(poemName, LINES);

}

}

Haiku.java

public class Haiku extends Poem

{

private static int LINES = 3;

public Haiku(String poemName)

{

super(poemName, LINES);

}

}

Limerick.java

public class Limerick extends Poem

{

private static int LINES = 5;

public Limerick(String poemName)

{

super(poemName, LINES);

}

}

Poem.java

public class Poem

{

private String poemName;

private int lines;

public Poem(String poemName, int lines)

{

this.poemName = poemName;

this.lines = lines;

}

public String getPoemName()

{

return poemName;

}

public int getLines()

{

return lines;

}

}

DemoPoem.java

import java.util.*;

public class DemoPoems

{

public static void main(String[] args)

{

Poem poem1 = new Poem("The Raven", 84);

Couplet poem2 = new Couplet("True Wit");

Limerick poem3 = new Limerick("There was an Old Man with a Beard");

Haiku poem4 = new Haiku("The Wren");

display(poem1);

display(poem2);

display(poem3);

display(poem4);

}

public static void display(Poem p)

{

System.out.println("Poem: " + p.getPoemName() +

" Lines: " + p.getLines());

}

}

Explanation:

The Couplet and Limerick classes should also be <u>extended from Poem class</u>. Also, in display method, you call getTitle(), however, it's written as getPoemName() in the <em>Poem</em> class. You need to change the name.

You might be interested in
Technician A says that PTC heaters can be built into a conventional heater core assembly. Technician B says that a PTC heater's
Art [367]

Answer:

A) Technician A only.

Explanation:

Only Technician A who said that Positive Temperature Coefficient (PTC ) heaters can be built into a conventional heater core assembly is correct because they use the same heat loss and transfer system. This is easily verifiable with a simulation.

Technician B, who said that a PTC heater's electrical resistance will decrease as its temperature increases is incorrect because the resistance of a conductor is directly proportional to temperature. This means that a PTC heater's electrical resistance will increase as its temperature increases.

7 0
3 years ago
On the Picture Tools Layout tab, you can preview results of the numerous styles, borders, effects, and layouts by _______ comman
Doss [256]
He correct answer is A
5 0
4 years ago
Read 2 more answers
Social media first became popular due to which development?
kvv77 [185]
I think it's A because it sounds more reasonable
5 0
2 years ago
Consider the problem of solving two 8-puzzles.
Law Incorporation [45]

Answer:

See Explaination

See Explaination

Explanation:

d. If both players play perfectly, then too each player will play not let the other win. Let there be a state of the game in which the goal state can be achieved in just 2 more moves. If player 1 makes one move then the next move made player 1 will win or player 2 do the same.

Either way whatever the rule states, there must be a winner emerging.

Check attachment for option a to c.

3 0
3 years ago
________ are found on the motherboard and are used to attach your hard disk.
Naya [18.7K]
<span>SATAs are found on the motherboard and are used to attach your hard disk.
</span>The SATA standard is most often used today by hard drives to communicate with a system motherboard. SATA stands for <span>Serial AT Attachment.
</span>It is a computer bus<span> interface that connects </span>host bus adapters<span> to </span>mass storage devices<span> such as </span>hard disk drives<span>, </span>optical drives<span>, and </span>solid-state drives<span>.</span>

4 0
3 years ago
Other questions:
  • You know a Linux command will perform a desired function for you, but you cannot remember the full name of the command. You do r
    14·1 answer
  • Write a program that loops one thousand times. add all the even numbers and display the results. add all the odd numbers and dis
    13·1 answer
  • What error, if any, is in the following code?
    11·1 answer
  • 안녕하세요! 한국어도 여기서 사용 가능한지 궁금합니다.
    6·2 answers
  • What is a row of data in a database called?<br> Field<br> File<br> Record<br> Title
    10·1 answer
  • What is trouble shoot​
    11·1 answer
  • "What is the capital of Belarus?" is an example of what type of search query
    10·2 answers
  • What is the component on the motherboard that confirms all devices are in working order once the computer is turned on?
    13·1 answer
  • Create a function called is_list_empty that takes a single argument of type list. Your function should return True if the list i
    7·1 answer
  • Please tell fast plzzzzzzz​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!