forked from League-Archive/IntroToJavaWorkshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpeakAndSpell.java
More file actions
39 lines (26 loc) · 957 Bytes
/
SpeakAndSpell.java
File metadata and controls
39 lines (26 loc) · 957 Bytes
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
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) {
// 1. Use the speak method to say the word. "e.g. spell mandlebrot"
// 2. Catch the user's answer in a String
// 3. If the user spelled the word correctly, speak "correct"
// 4. Otherwise say "wrong"
// 5. repeat the process for other words
}
static void speak(String words) {
try {
Runtime.getRuntime().exec("say " + words).waitFor();
} catch (Exception e) {
e.printStackTrace();
}
}
}