import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.*;
class Project
{ // beginning of class
public static void main (String[]args)
{ // beginning of main
int choice2, answer2, answer4;
choice2 = 1;
answer2 = 0; // initializes it so it won't give error
answer4 = 0;
String noun, adjective, verb, noun2, adjective2, verb2, choice, answer, answer3;
noun = "";
adjective = "";
verb = "";
noun2 = "";
adjective2 = "";
verb2 = "";
choice = "";
answer = "";
answer3 = "";
try
{ // beginning of try
while (choice2 == 1)
{ // beginning of while
answer = JOptionPane.showInputDialog(null, "Hello! Which story would you like to see? Type either '1', '2', or '3' to choose your story.", "Choose your story!", JOptionPane.INFORMATION_MESSAGE);
answer2 = Integer.parseInt(answer);
noun = typeinNoun();
verb = typeinVerb();
adjective = typeinAdjective();
noun2 = typeinNoun2();
verb2 = typeinVerb2();
adjective2 = typeinAdjective2();
if (answer2 == 1)
{ // beginning of if
typein();
JOptionPane.showMessageDialog(null, "The " + noun + " went on a stroll in the " + adjective + " park and " + verb + " the tree. Then, a " + noun2 + " came out of nowhere and " + verb2 + " on the " + adjective2 + " mole.", "Story", JOptionPane.INFORMATION_MESSAGE);
choice = JOptionPane.showInputDialog(null, "Do you want to redo the story? Press '1' for yes and '2' for no.", "Restart?", JOptionPane.INFORMATION_MESSAGE);
choice2 = Integer.parseInt(choice);
} // end of if
else if (answer2 == 2)
{ // beginning of else if
typein();
JOptionPane.showMessageDialog(null, "The " + noun + " went on a stroll in the " + adjective + " park and " + verb + " the tree. Then, a " + noun2 + " came out of nowhere and " + verb2 + " on the " + adjective2 + " mole.", "Story", JOptionPane.INFORMATION_MESSAGE);
choice = JOptionPane.showInputDialog(null, "Do you want to redo the story? Press '1' for yes and '2' for no.", "Restart?", JOptionPane.INFORMATION_MESSAGE);
choice2 = Integer.parseInt(choice);
} // end of else if
else if (answer2 == 3)
{ // beginning of else if
typein();
JOptionPane.showMessageDialog(null, "The " + noun + " went on a stroll in the " + adjective + " park and " + verb + " the tree. Then, a " + noun2 + " came out of nowhere and " + verb2 + " on the " + adjective2 + " mole.", "Story", JOptionPane.INFORMATION_MESSAGE);
choice = JOptionPane.showInputDialog(null, "Do you want to redo the story? Press '1' for yes and '2' for no.", "Restart?", JOptionPane.INFORMATION_MESSAGE);
choice2 = Integer.parseInt(choice);
} // end of else if
else
{ // beginning of else
JOptionPane.showMessageDialog(null, "Please type in a number from 1 to 3!", "Wrong Number!", JOptionPane.INFORMATION_MESSAGE);
} // end of else
} // end of while
if (choice2 == 2)
{ // beginning of if
answer3 = JOptionPane.showInputDialog(null, "Do you want to see another story? Please type '1' for yes and '2' for no.", "Other Story", JOptionPane.INFORMATION_MESSAGE);
answer4 = Integer.parseInt(answer3);
if (answer4 == 1)
{ // beginning of if
choice2 = 1;
} // end of if
else if (answer4 == 2)
{ // beginning of else if
JOptionPane.showMessageDialog(null, "Goodbye!", "End of Stories", JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
} // end of else if
else
{ // beginning of else
JOptionPane.showMessageDialog(null, "Please choose either 1 or 2!", "Wrong Number!", JOptionPane.INFORMATION_MESSAGE);
} // end of else
} // end of if
} // end of try
catch (java.lang.Throwable n)
{ // beginning of catch
JOptionPane.showMessageDialog(null, "Goodbye!", "Clicked Cancel", JOptionPane.INFORMATION_MESSAGE);
} // end of catch
} // end of main
// if it still can't find them as is, have the respective Strings as parameters.
// like this
/*
static String typeinNoun(String noun)
{ // beginning of method
noun = JOptionPane.showInputDialog(null, "Type in a noun.", "Noun");
return(noun);
} // end of method
I'm not sure if it needs you to pass the parameters, so I'm leaving this in case you do
if you do need them, call it like this:
noun = typeInNoun(noun);
*/
static String typeinNoun()
{ // beginning of method
noun = JOptionPane.showInputDialog(null, "Type in a noun.", "Noun");
return(noun);
} // end of method
static String typeinAdjective()
{ // beginning of method
adjective = JOptionPane.showInputDialog(null, "Type in an adjective.", "Adjective");
return(adjective);
} // end of method
static String typeinVerb()
{ // beginning of method
verb = JOptionPane.showInputDialog(null, "Type in the past form of a verb.", "Verb");
return(verb);
} // end of method
static String typeinNoun2()
{ // beginning of method
noun2 = JOptionPane.showInputDialog(null, "Type in another noun.", "Noun");
return(noun2);
} // end of method
static String typeinVerb2()
{ // beginning of method
verb2 = JOptionPane.showInputDialog(null, "Type in another past form of a verb.", "Verb");
return(verb2);
} // end of method
static String typeinAdjective2()
{ // beginning of method
adjective2 = JOptionPane.showInputDialog(null, "Type in another adjective.", "Adjective");
return(adjective2);
} // end of method
} // end of program