import java.io.*; import java.util.*; public class MadStory { private LinkedList story = new LinkedList(); private Stack prompts = new Stack(); private boolean isReady = false; // Read a story from the file. public void readFromFile(String filename) { // read a line of data // while input OK { // Call your MadUtils.smartSplit() method. // It should indicate that it got a blank link with null. // This means it's a paragraph break - if it returns null, // add an empty string to your story, read a line, then continue. // Not a paragraph break, so add the words to the story. // read a line of data } datafile.close(); } // Set up the game public boolean setupGame(BufferedReader keyboard, MadDictionary dictionary) throws IOException { MadPrompt p; StringBuffer madDef; String str; int numWords = 0; // Iterate through the story for (String word : story) { numWords++; str = MadUtils.getMadWord(word); if (str != null) { // ----------- You write the code -----------// // Look up the definition in the dictionary, using your MadUtils.lookupWord() method // create a MadPrompt using numWords and the definition // add it to the Stack (use the proper method for a Stack) } } Utils.printStack(prompts); isReady = true; return true; } // Play the game public boolean play(BufferedReader keyboard) throws IOException { String str; MadPrompt p; if (!isReady) return false; isReady = false; // ----------- You write the code -----------// // Process the MadPrompts stack - use the proper terms and method // for procesisng a Stack. // For each MadPrompt taken off the Stack, prompt the user (use Utils.getIndefiniteArticle()) // then use the entered value to replace the mad word in the story LinkedList. return true; } // ----------- You write the code -----------// // Print the story to the screen // Be sure to show the paragraph markers. // Start by printing the MadWords, then update it to format it into lines of n characters, // with the MadWord replaced with underscores and the MadPrompt on the line below. public void print(int n) { } }