Game 5: Guess-A-Word Game
Assume you are given a file, called words.txt, with a number of five-letter words as follows:
b,a,s,i,c
l,a,b,e,l
s,t,o,r,e
w,o,r,d,s
q,u,e,r,y
g,u,e,s,s
r,i,g,h,t
w,r,o,n,g
t,h,i,n,k
l,o,o,p,s
Each record in the file consists of 5 fields, each containing a character of the word in the order
that they appear in the given word.
Page 5 of 6
Write a game that generates a random number (in the range 1 to number of records in the file, 10
in our case) and retrieves the random number record from the file (for example, if the random
number is 4 then the 4th record should be retrieved). The player is then asked to guess each
different character in the five-letter word. Each time the player guesses a correct letter of the
word then the character(s) should be displayed in the appropriate text box(es) on the user
interface, in the order that they appear in the word. (If a character appears more than once in a
word then all occurrences of the character should be displayed in the appropriate textboxes.) The
maximum number of incorrect guesses that the player should be allowed is 4. Each time a wrong
guess is chosen, an X should appear in one of the four “wrong guess” textboxes on the interface.
The process should stop if the player has guessed the complete word (i.e., all five textboxes
contain the letters of the word) or the maximum number of incorrect guesses has been reached
(4). In addition, your program should display an appropriate message to indicate whether the
player has guessed the complete word or not. Note, to help the user remember which letters
he/she has already guessed, each guess (correct or incorrect) should be displayed in a picture box
on the user interface as the user is playing the game.
|