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
A ____________ variable is available throughout a program.
kvv77 [185]

Answer:

global

Explanation:

Its the global variable, and its scope is the whole program. And hence, a global variable is available throughout the program. And you need to know that a local variable has its scope in the block where it has been declared. Its scope is that block or the function or the loop only. And if you want it to have a global scope, then you will have to declare it as a global variable.

3 0
3 years ago
The use of desktop computer equipment and software to create high-quality documents such as newsletters, business cards, letterh
-Dominant- [34]

Answer: the first stage of any proposed DTP project should be organization and design.

Explanation:

The options to the question include:

A. Desktop Publishing is one way to become acquainted with a new business audience.

B. computer software is continually being refined to produce high quality printing.

C. the first stage of any proposed DTP project should be organization and design.

D. the planning stage of any DTP project should include talking with the intended audience.

The paragraph best supports the statement that the first stage of any proposed DTP project should be organization and design.

This can be infered from the statement that "Before you begin, you should know your intended audience, the message you want to communicate, and what form your message will take".

5 0
3 years ago
TCP will guarantee that your packets will arrive at the destination, as long as the connection is still established. True False
puteri [66]

Answer: True

Explanation: TCP(Transmission control protocol) is the protocol that is responsible for making the connection between the two hosts and then  they can share the data between them.

TCP guarantees that the data or data packets that are being sent from the source will be delivered to the host  in the same way as it was sent from source port. This mechanism ensure that there will be no data manipulation in the order of the data. TCP also has a relation with the IP for the functioning.Thus the given statement is true.

3 0
3 years ago
Larry does not want to save his Internet browsing details on his computer what files delete to clear his information from the co
GREYUIT [131]
He would have to clear his history or use incognito tabs from then on.
5 0
4 years ago
What's is the contribution of technology to the country?
slamgirl [31]
To help us get news from different countries
8 0
3 years ago
Other questions:
  • What is the full form of the acronym WWW?
    13·2 answers
  • i will be doing an interview to someone so plz comment down below something random and you will automatically enter
    11·1 answer
  • What is the definition of D1-D4?
    14·1 answer
  • Hey guys im just curious.... whats ur favorite number
    6·2 answers
  • Plain text and ASCII text are the same thing. true or false
    12·1 answer
  • How does a project charter support the project manager in getting things for the project from other people?
    6·1 answer
  • In order to enhance the training experience and emphasize the core security goals and mission, it is recommended that the execut
    5·1 answer
  • Many web pages use a <br> structure to define an area of focus
    13·1 answer
  • Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    12·1 answer
  • What service determines which resources a user can access along with the operations that a user can perform?.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!