CS 107 (Spring '09)
[Schedule]
[Programs]
[Notes
& Reference] [Examples][Syllabus]
[Lab & TA] [Tests]
[Grades]
Prof. Reed, CS 107, Fall '08
Due Monday 9/29 at 12:00 noon
Changes to the description below made after the original publishing shown in green, and additional subsequent changes shown in blue
Write a program in Java to fill out a 3 x 3 crossword puzzle. This idea is taken from the online game found at http://www.funbrainpuzzle.com/puzzle_e00.htm. Running your program will look something like what is shown below, where user input is shown in bold:
Author: Dale Reed
Program: #2, WordSquare
TA: Englebert Humberdink, T 4-5
Sept 9, 2008
Welcome to the 3x3 crossword puzzle.
This idea is taken from: http://www.funbrainpuzzle.com/puzzle_e00.htm
Each row and each column forms a 3 letter word.
On each move enter either a number for a row (1,2, or 3) or a letter
for a column (A,B, or C), and then the 3 letter word to be placed there.
For example, entering:
2 cat
would place the word "cat" across the row 2. Similarly, entering:
C dog
would place the word "dog" down column 3. In each case user input overwrites
what is already in those spaces. At any point type in "check" (without the
quotes) to check your answer so far. At any point enter "exit" (without the
quotes) to exit the program
Let's begin.
Across Down
1. long ___ and far away A. a feeling of great respect
2. fighting between nations B. cheerful and excited
3. used for seeing C. what metal is extracted from
A B C
1 . . .
2 . . .
3 . . .
1. Please enter your move: b yay
Across Down
1. long ___ and far away A. a feeling of great respect
2. fighting between nations B. cheerful and excited
3. used for seeing C. what metal is extracted from
A B C
1 . y .
2 . a .
3 . y .
2. Please enter your move: 2 war
Across Down
1. long ___ and far away A. a feeling of great respect
2. fighting between nations B. cheerful and excited
3. used for seeing C. what metal is extracted from
A B C
1 . y .
2 w a r
3 . y .
3. Please enter your move: 3 eye
Across Down
1. long ___ and far away A. a feeling of great respect
2. fighting between nations B. cheerful and excited
3. used for seeing C. what metal is extracted from
A B C
1 . y .
2 w a r
3 e y e
4. Please enter your move: check
There are errors at board positions shown below:
1 2 3
. . .
. . .
Please keep trying.
Across Down
1. long ___ and far away A. a feeling of great respect
2. fighting between nations B. cheerful and excited
3. used for seeing C. what metal is extracted from
A B C
1 . y .
2 w a r
3 e y e
5. Please enter your move: d oop
User input was invalid. Please retry your move.
Across Down
1. long ___ and far away A. a feeling of great respect
2. fighting between nations B. cheerful and excited
3. used for seeing C. what metal is extracted from
A B C
1 . y .
2 w a r
3 e y e
6. Please enter your move: 3 eyes
User input was invalid. Please retry your move.
Across Down
1. long ___ and far away A. a feeling of great respect
2. fighting between nations B. cheerful and excited
3. used for seeing C. what metal is extracted from
A B C
1 . y .
2 w a r
3 e y e
7. Please enter your move: 1 ago
Across Down
1. long ___ and far away A. a feeling of great respect
2. fighting between nations B. cheerful and excited
3. used for seeing C. what metal is extracted from
A B C
1 a g o
2 w a r
3 e y e
8. Please enter your move: check
*** Well done! You got it right! ***
Thanks for playing!
Exiting Program...
// Main loop, which displays the board, prompts for user input, and makes the updates.
while ( notDone) {
// Display the board
// ... your code that you already wrote should go here ...
// Prompt for user input and get user input
// ... your code that you already wrote should go here ...
}//end while (notDone)
Now compile and run your code and make sure it works. Note that your program will be in an infinite loop, so to exit you will need to close the Terminal Window, or right-click on the horizontal "barber pole" near the bottom-left of the BlueJ window to stop the program that is running
// Main loop, which displays the board, prompts for user input, and makes the updates.
while ( notDone) {
// Display the board
// ... your code here ...
// Prompt for user input and get user input
// ... your code here ...
// Check for special user input word "exit"
// ... your code here ...
// Check for special user input word "check"
// ... your code here ...
// Verify user input. Input should be 5 characters long, have a 1,2,3,a,b, or c in the
// first character, and should have a space in the second character.
// ... your code here ...
// If we got to here, then user input should be valid. Make the move, reflecting the user input.
// ... your code here ...
}//end while (notDone)
turnin -c cs107 -p program2 BoardSquare.java
where the file containing your solution is called BoardSquare.java . Please do not name your program anything besides BoardSquare.java ls -l ~i107/submit/program2
You must turnin this assignment using the turnin command. No email solutions will be accepted, unlike the first program.
[CS Dept] [UIC] [Prof. Reed]