Classwork:
Write an OOD application, YI_WordValue.java to calculate the value of a word in the Scrabble game. Prompt the user for a word and display it worth using the table below:
Write the tester class using a dialog box for user input.
Using dialog boxes
The JOptionPane class has the static showInputDialog method of t and supply the string that
prompts the input from the user.
Some examples:
String input = JOptionPane.showInputDialog(“Enter a word:”);
That method returns a String object.
You can also display output in a dialog box:
JOptionPane.showMessageDialog(null, “Word value: ” + worth);
Any time you invoke the showInputDialog or showMessageDialog method in a program that
does not show any other frame windows, you need to add a line
System.exit(0);
to the end of your main method.
The showInputDialog method starts a user interface thread to handle user input. When the main method reaches the end, that thread is still running, and your program won’t exit automatically.
Calling the static method exit() from the System class, will force the program to exit. The parameter is the program’s status code. Zero represents a successful execution.
0 when execution went fine;
1, -1, whatever != 0 when some error occurred, you can use different values for different kind of errors.