forked from jointheleague/IntroToJavaWorkshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpeakAndSpell.java
65 lines (45 loc) · 1.24 KB
/
SpeakAndSpell.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package day3;
import javax.swing.JOptionPane;
/**
* Teacher's Note: Have the kids play with the Speak & Spell. The first Speak &
* Spell was introduced at the summer Consumer Electronics Show in June 1978,
* making it one of the earliest handheld electronic devices with a visual
* display to use interchangeable game cartridges. Discuss with students how you
* would make this program. Allow them to code it themselves, or use this
* recipe.
**/
public class SpeakAndSpell {
public static void main(String[] args) {
speak("Spell Mandlebrot");
String input = JOptionPane.showInputDialog("spell the word");
if (input.equals("mandlebrot")) {
speak("correct");
}
else {
speak("wrong");
}
speak("Spell duckling");
String answer = JOptionPane.showInputDialog("spell the word");
if (answer.equals("duckling")) {
speak("correct");
}
else {
speak("wrong");
}
speak("Spell vowels");
String input2 = JOptionPane.showInputDialog("spell the word");
if (input2.equals("vowels")) {
speak("correct");
}
else {
speak("wrong");
}
}
static void speak(String words) {
try {
Runtime.getRuntime().exec("say " + words).waitFor();
} catch (Exception e) {
e.printStackTrace();
}
}
}