File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Write a program to guess a word by trying to guess the individual characters.
3
+ * The word to be guessed shall be provided using the command-line argument.
4
+ *
5
+ * Your program shall look like:
6
+ * > java WordGuess testing
7
+ * Key in one character or your guess word: t
8
+ * Trail 1: t__t___
9
+ * Key in one character or your guess word: g
10
+ * Trail 2: t__t__g
11
+ * Key in one character or your guess word: e
12
+ * Trail 3: te_t__g
13
+ * Key in one character or your guess word: testing
14
+ * Trail 4: Congratulation!
15
+ * You got in 4 trials
16
+ *
17
+ * Hints:
18
+ * 1. Set up a boolean array to indicate the positions of the word
19
+ * that have been guessed correctly.
20
+ * 2. Check the length of the input String to determine whether the player enters
21
+ * a single character or a guessed word. If the player enters a single character,
22
+ * check it against the word to be guessed, and update the boolean array that
23
+ * keeping the result so far.
24
+ * 3. Try retrieving the word to be guessed from a text file (or a dictionary) randomly.
25
+ */
26
+
27
+ package javaexercises .difficult ;
28
+
29
+ public class WordGuess {
30
+
31
+ public static void main (String [] args )
32
+ {
33
+ WordGuess aWordGuess = new WordGuess ();
34
+ }
35
+
36
+ }
You can’t perform that action at this time.
0 commit comments