So this is the question. Mab Libs is a children\'s game in which they provide a
ID: 3540902 • Letter: S
Question
So this is the question.
Mab Libs is a children's game in which they provide a few words that are then incorporated into a silly story. The game helps children understand different parts of speech because they are asked to provide specific types of words. For example, you might ask a child for a noun, another noun, an adgective, and a past-tense verb. The child might reply with such answers as table, book, silly, and studied. The newly created Mab Lib might be: Mary had a little table its book was silly as snow and everwhere that Mary studied The table was sure to go Create a Mad Lib program that asks the user to provide at least four or five words then created and display a short story or nursery rhyme that uses them. Same the file as MadLib.java.
And this are the special instructions that i need:
- Use the JOptionPane class to acquire a minimum of six words from the user to include in the Mad Lib.
- Ask the user if they would like to play the game again with a Confirm Dialog box using the JOptionPane.YES_NO_OPTION. If yes, ask the user for new words and redisplay the new Mad Lib using them.
import java.awt.*; import java.awt.event.*; public class MadLib extends Frame implements WindowListener { private TextArea display; private MadDialog dialog; public MadLib() { super("MadLib Game"); display = new TextArea(" ", 7, 60, TextArea.SCROLLBARS_VERTICAL_ONLY); display.setFont(new Font("Arial", Font.PLAIN, 16)); display.setEditable(false); add(display); addWindowListener(this); setLocation(100, 150); pack(); dialog = new MadDialog(this); dialog.addWindowListener(this); dialog.setLocation(150, 100); dialog.setVisible(true); setVisible(true); } public static void main(String[] args) { MadLib ml = new MadLib(); } private void buildStory() { String story = " "; String[] segs = {"Be kind to your ", " End Table, footed", " Films", " ", " For a duck may be somebody`s ", " ", " End Table ", " Be kind to your ", " ", " ", " Films in", " Costa Rica", " ", ". Where the weather is ", " always Unchanged, "", "" ", " ", " You may think that ", ", this is the ", " ", " ", " End Table", " ", " Well ", " it is ", "." }; String[] s = dialog.getStringarray(); for (int i = 0; i < s.length; i++) { story += segs[i] + s[i]; } story += segs[segs.length - 1]; display.setText(story); } public void windowClosing(WindowEvent e) { if (e.getSource() == this) { dispose(); System.exit(0); } else if (e.getSource() instanceof Dialog) { buildStory(); ((Dialog)e.getSource()).setVisible(false); } } //the rest of them must be delcared public void windowActivated(WindowEvent e) { } public void windowClosed(WindowEvent e) { } public void windowIconified(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowDeactivated(WindowEvent e) { } public void windowOpened(WindowEvent e) { } } I also keep having an error that MadDialog can't be found which I thought was odd cause I thought I declared it and created one. Please help me modify this code.
Explanation / Answer
there is no MadDialog class.that why you are getting errors.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.