Question: import java.util. * ; public class MadLib extends ConsoleProgram { / / Private constants private static final char PLACEHOLDER _ START _ CHARACTER = '

import java.util.*;
public class MadLib extends ConsoleProgram
{
// Private constants
private static final char PLACEHOLDER_START_CHARACTER ='[';
private static final char PLACEHOLDER_END_CHARACTER =']';
// File reader to get the template from the "madlib.txt" file
private MadLibFileReader madLibFileReader = new MadLibFileReader();
public void run()
{
// Gets the contents of the file "madlib.txt" as a String
// This will be the template for our Mad Lib Story
String template = madLibFileReader.getMadLibTemplate();
ArrayList placeholders = getPlaceholders(template);
if (placeholders != null){
for (String placeholder : placeholders){
System.out.println(placeholder);
}
} else {
System.out.println("Error: Malformed template!");
}
}
private ArrayList getPlaceholders(String template){
String template = "The [Adjective][Noun] jumped over the [Adjective][Noun].";
ArrayList placeholders = getPlaceholders(template);
for(int i =0; i < placeholders.size(); i++)
{
System.out.println(placeholders.get(i));
}
}
}

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 Databases Questions!