mad libs with JAVA
stuck with the giant loop to connect it.
There was once a who in a .
Everyone in the was of the ,
but no one had the to . So we
past the and upon the ,
and everyone felt about their lot in life, until, of course,
the descended upon us like and took
from us. Rue that day! Rue it .
coolStory = new ArrayList(); //the new redone story while (line.contains("<") &&="" line.contains("="">")) { String part = "."; if (line.charAt(line.length()-1) =='.' || line.charAt. length()-1 ==',') { // for adi rnd = coolStory.add(adjs()); } else if (line.charAt(line.length()-1) ='.' || line.charAt. length()-1 ==',') { // adverb } else if (line.charAt(line.length()-1) ='.' || line.charAt.length()-1 ==',') { // singnoun } else if (line.charAt(line.length()-1) =='.' || 1line.charAt.length()-1 ==',') { // plunoun } else if (line.charAt (line.length()-1) =='.' || 1line.charAt.length()-1 ==',') { /I singverb } else if (line.charAt (line.length()-1) =='.' || 1line.charAt.length()-1 ==',') { /I pluverb } else if (line.charAt(line.length()-1) =='.' || 1line.charAt.length()-1 ==',') { // pastverb } "/>
Extracted text: //STORY TIME else { try { Scanner fsc = new Scanner(new File("story" + option +".txt")); System.out.println(); while (fsc.hasNextLine()) { line = fsc.nextLine(); String[] parts = line.split(" "); ArrayList coolStory = new ArrayList(); //the new redone story while (line.contains("<") &&="" line.contains("="">")) { String part = "."; if (line.charAt(line.length()-1) =='.' || line.charAt. length()-1 ==',') { // for adi rnd = coolStory.add(adjs()); } else if (line.charAt(line.length()-1) ='.' || line.charAt. length()-1 ==',') { // adverb } else if (line.charAt(line.length()-1) ='.' || line.charAt.length()-1 ==',') { // singnoun } else if (line.charAt(line.length()-1) =='.' || 1line.charAt.length()-1 ==',') { // plunoun } else if (line.charAt (line.length()-1) =='.' || 1line.charAt.length()-1 ==',') { /I singverb } else if (line.charAt (line.length()-1) =='.' || 1line.charAt.length()-1 ==',') { /I pluverb } else if (line.charAt(line.length()-1) =='.' || 1line.charAt.length()-1 ==',') { // pastverb }
advs = readwordList("adv.txt"); do { ask them what they want if they chose i show them the instructions else { try { Scanner fsc = new Scanner(new File("story" + what they typed in + ".txt")); for each line in the file replace the , , etc with random words from the adjs, advs, etc. lists } catch (Exception ex) { say the file didn't exist } } while they chose not to quit "/>
Extracted text: *Untitled - Notepad File Edit Format View Help public ArrayList readWordList(String fname) { try { ArrayList results = new ArrayList(); Scanner fsc = new Scanner(new File(fname)); for each line in the fsc you just opened: add the line to the results list close the fsc return results; } catch (Exception ex) { return null; } } in main ArrayList adjs = readwordList("adj.txt"); ArrayList advs = readwordList("adv.txt"); do { ask them what they want if they chose i show them the instructions else { try { Scanner fsc = new Scanner(new File("story" + what they typed in + ".txt")); for each line in the file replace the , , etc with random words from the adjs, advs, etc. lists } catch (Exception ex) { say the file didn't exist } } while they chose not to quit")>")>