Class MadlibFiller
java.lang.Object
madlibgeneration.MadlibFiller
Utility class that takes madlibified madlib (txt file with some words replaced by [part of speech] blocks) and fills in with user's replacement words collected from the CLI
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidfillInMadlib(BufferedWriter writer, String blankedMadlib, Queue<String> replacementWords) Responsible for replacing the part of speech blocks in the blanked madlib with the list of words prompted by the CLIprivate static voidreplaceWord(Queue<String> replacementWords, String lastChar, boolean lastWord, BufferedWriter writer) Helper method for parsing and formatting words in the blanked madlib based on whether a word should be replaced or not
-
Constructor Details
-
MadlibFiller
MadlibFiller()
-
-
Method Details
-
fillInMadlib
void fillInMadlib(BufferedWriter writer, String blankedMadlib, Queue<String> replacementWords) throws IOException Responsible for replacing the part of speech blocks in the blanked madlib with the list of words prompted by the CLI- Parameters:
blankedMadlib- Text resulting from the MadlibBlanker that has a number of words replaced by text blocks displaying their associated parts of speechreplacementWords- The list of words the user chose to replace each removed word (prompted by the CLI class).- Throws:
IOException
-
replaceWord
private static void replaceWord(Queue<String> replacementWords, String lastChar, boolean lastWord, BufferedWriter writer) throws IOException Helper method for parsing and formatting words in the blanked madlib based on whether a word should be replaced or not- Parameters:
lastChar- Determines if the last character of the word is punctuation. If it is, we need to maintain that punctuation after removing the text block and replacing the word.lastWord- If a word is the last word on a line, do not add a space at the end.- Throws:
IOException
-