Prog 5: Crossword Puzzle

Prof. Reed, CS 102, Fall 2011

Due at 11:59pm on the date indicated in the Course Schedule

No partners on this project.  You must complete it on your own. 

Write a crossword puzzle program that allows you to play an existing crossword puzzle, where the clues and the contents for the crossword puzzle come from a file. Write your program in stages as described below.

Stage 1 (15 points): 

Read crossword puzzle information from a file and display it as a crossword board.

For this stage assume the crossword puzzle clues are stored in a file called "clues.txt". For example this file could contain the following:

hexadecimal a1 a base 16 asterisk    g4 a catch with an _ ampersand   a4 d pass with an _ bit         d1 d 8 _s make a byte byte        d1 a does your cyber-dog _? seo         d6 a office in 917 _ sense       c7 d common _ kilo        f9 d K, as in _bytes

The first 11 characters are the word (e.g. "hexadecimal"). All words must be of size 11 or less. After a space, the next two characters (e.g. "a1") are the row ('a') and the column ('1') where the words starts. After a space the next character ('a') is the direction of the word, where 'a' means across, and 'd' means down. After a space the next 25 characters (or less) store the text of the clue for that word.

Read in the contents of this file and use it to create and display the board. See the bottom of this page for the attached program parseSample.cpp which illustrates part of what you need to read the input file. In the case of the above file, running the program would look like the following:

About to read from input file...    0 1 2 3 4 5 6 7 8 91011 a  * h e x a d e c i m a l b  * * * * m * * * * * * * c  * * * * p * * s * * * * d  * b y t e * s e o * * * e  * i * * r * * n * * * * f  * t * * s * * s * k * * g  * * * * a s t e r i s k h  * * * * n * * * * l * * i  * * * * d * * * * o * * j  * * * * * * * * * * * * k  * * * * * * * * * * * * l  * * * * * * * * * * * *  ACROSS:                                 Row Col Clue                        0. a   1  base 16                     1. g   4  catch with an _             4. d   1  does your cyber-dog _?      5. d   6  office in 917 _             DOWN:      Row Col Clue 2. a   4  pass with an _  3. d   1  8 _s make a byte  6. c   7  common _  7. f   9  K, as in _bytes

Note that there is a maximum of 8 across clues, and a maximum of 8 down clues. You may assume that the data file is always correctly formatted. You must store the board as a two-dimensional array. I suggest you create two separate arrays in which to store the across and down clues. Number the clues sequentially as found in the original clues file. These numbers will be used to later uniquely refer to the clues when guessing words. 

Stage 2 (15 points):

Allow solving a crossword puzzle

For stage 2 the empty board containing asterisks and appropriate blank spaces and the clues are displayed. This looks like the following:

  0 1 2 3 4 5 6 7 8 91011 a  *   b  * * * *   * * * * * * * c  * * * *   * *   * * * * d  *         *       * * * e  *   * *   * *   * * * * f  *   * *   * *   *   * * g  * * * *   h  * * * *   * * * *   * * i  * * * *   * * * *   * * j  * * * * * * * * * * * * k  * * * * * * * * * * * * l  * * * * * * * * * * * *

ACROSS:                                 Row Col Clue                        0. a   1  base 16                     1. g   4  catch with an _             4. d   1  does your cyber-dog _?      5. d   6  office in 917 _             DOWN:      Row Col Clue 2. a   4  pass with an _  3. d   1  8 _s make a byte  6. c   7  common _  7. f   9  K, as in _bytes

Please choose the number of a word to guess or x to exit -> 3 Please enter your guess: hits  Sorry, 'hits' is not correct.  Press enter to continue...

Then the screen is cleared and play continues. When a word is guessed correctly, it is then subsequently stored on the board every time it is displayed that game. Correctly guessing all words offers a congratulatory message which could be something like:

Good Job, you guessed them all!  Press enter to continue...

The program ends after either guessing all the words or entering x to exit.

Stage 3 (25 points):

Allow user to get help for a particular word.  User input of 'c' (to "cheat") prompts for the word position, then gives all words in the dictionary that could fit in that space, given any other characters currently displayed there.  Use the same dictionary that we used for the previous program.  See the attached files for sample code and for the dictionary.

This should look like:

Please choose the number of a word to guess or x to exit -> c

Enter the word position -> 3

Possible words are:

Then the list of all possible words at that point in the game should be displayed.  If there are no letters in any of those spaces, then in this case all 3 letter words would be displayed.  If there are some letters already displayed, then only the 3 letter words that also match those letters would be displayed.

You need to know the following concepts in order to write this program:

Notes: