answer.
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
1 year 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]1 year 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
Cloud storage refers to the storage of data on ______.a. your mobile device.b. your desktop computer.c. an external drive.d. a s
eimsori [14]

Answer:

D.  server on the internet

Explanation:

6 0
1 year ago
Which of the following is true with regard to defensive programming? Preconditions should never be visible to callers. Program c
Firlakuza [10]

Answer:

The correct point about defensive programming is that the "program code frequently assumes that input will be valid and that algorithms will behave as expected".

Explanation:

8 0
1 year ago
Assign test_stat_72 to the value of the test statistic for the years 1971 to 1973 using the states in death_penalty_murder_rates
Alika [10]

Answer:

Find attached below the solution and explanation to the problem.

Explanation:

3 0
2 years ago
Which element of the word program window contains buttons for saving a document and for undoing, redoing, and repeating a change
miskamm [114]
The answer is the Quick Access Toolbar. However, it is not only for saving files or undoing your work. Containing a set of commands that are independent, this toolbar is actually customizable wherein you could change these icons to the ones you really need and frequently use. By tweaking the settings, you can even add commands to the Quick Access Toolbar that are not in the ribbon (like New, Open and Print).
7 0
2 years ago
You're the sole IT employee at your company, and you don't know how many users or computers are in your organization. Uh oh! Wha
Neporo4naja [7]

Answer

Directory Services

<u></u>

<u>Definition</u>

It is a type of software that is used to unify and customize the resources available at the network.

<u>Explanation</u>

This software is used to gather the information and addresses of all computers connected on the network.

It is a type of information store, where all the information related to resources (computer) and services of network has been stored. It also gives administrator rights to the single point to manage whole network resources.

This is the reason, Option "D" is the best choice for me as sole IT employ in a company. I will prefer directory services software to gather the information of all computers of organization and manage users in company.  

4 0
2 years ago
Other questions:
  • If a car's is malfunctioning, people in the car will become ill when driving long distances, especially if the windows are close
    6·2 answers
  • Suppose you develop an app and want to generate revenue but do not want to maintain the app. What would be your best choice?
    9·1 answer
  • Mr. Cooper would like to customize his Excel software so his students can create an electronic graph in Excel for their lab repo
    6·1 answer
  • A small company is moving towards sharing printers to reduce the number of printers used within the company. The technician has
    14·1 answer
  • Write the printItem() method for the base class. Sample output for below program:
    8·1 answer
  • The following parts were ordered by someone building a personal computer:
    12·1 answer
  • 14. Emelia is very concerned about safety and has conducted a study to determine how many bike helmets were replaced at each loc
    13·2 answers
  • 7.8.1: Function pass by reference: Transforming coordinates. Define a function CoordTransform() that transforms the function's f
    6·1 answer
  • A 1.17 g sample of an alkane hydrocarbon gas occupies a volume of 674 mL at 28°C and 741 mmHg. Alkanes are known to have the gen
    14·1 answer
  • How does Accenture help companies harness the power of data to achieve optimal business outcomes?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!