Answered step by step
Verified Expert Solution
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 PLACEHOLDERSTARTCHARACTER ;
private static final char PLACEHOLDERENDCHARACTER ;
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 getPlaceholderstemplate;
if placeholders null
for String placeholder : placeholders
System.out.printlnplaceholder;
else
System.out.printlnError: Malformed template!";
private ArrayList getPlaceholdersString template
String template "The AdjectiveNoun jumped over the AdjectiveNoun;
ArrayList placeholders getPlaceholderstemplate;
forint i ; i placeholders.size; i
System.out.printlnplaceholdersgeti;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started