Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions