[ Course Schedule ]
[ Syllabus ]
ITEC 120
HW4: Wheel of Fortune
Academic Integrity
Be reminded that this homework assignment must be your own work.
- You may not work on any homework assignment with another student.
- You may not copy material from another source.
- If you receive help from a tutor, you must include the name of the tutor in the header of your submitted code.
- For a more complete explanation of the Honor code, see the syllabus.
Objectives
After successfully completing this assignment you will be able to work with loops and String methods.
Assignment
Develop a program named Wheel.java which simulates a simple Wheel of Fortune style word game. Your program will prompt the user for phrase, then create and print a puzzle with blanks in place of letters, and punctuation filled in. The program will then prompt the user to guess letters until the puzzle is solved.
Here's a sample run (user input in red) :
Enter a phrase: Westward, Ho!
_ _ _ _ _ _ _ _ , _ _ !
Guess a letter: E
_ E _ _ _ _ _ _ , _ _ !
Guess a letter: s
_ E S _ _ _ _ _ , _ _ !
Guess a letter: t
_ E S T _ _ _ _ , _ _ !
Guess a letter: w
W E S T W _ _ _ , _ _ !
Guess a letter: a
W E S T W A _ _ , _ _ !
Guess a letter: r
W E S T W A R _ , _ _ !
Guess a letter: n
W E S T W A R _ , _ _ !
Guess a letter: o
W E S T W A R _ , _ O !
Guess a letter: h
W E S T W A R _ , H O !
Guess a letter: d
W E S T W A R D , H O !
Hooray! It took you 10 guesses.
Hints and tips
- This is the hardest homework you have had so far. It's essential that you break it into pieces. You should spend some time thinking about your algorithm before coding. Once you start coding, get some small piece of it to work before adding other parts.
- The puzzle in this example was created with underscore character _. If you put several underscore characters together, they look like a line, like so: ________. So, a space was put in between every character of the original phrase input by the user, like so: _ _ _ _ _.
- Notice that in this example, the puzzle is all uppercase, no matter what the user types in. Likewise, if the user guesses a lowercase letter, it matches uppercase letters. You'll save yourself some trouble if you convert all input to uppercase as soon as you read it in.
- Uppercase letters have an order, and they are consecutive. 'A' is less than 'Z'. A char is a primitive data type, and thus can be compared using the equality operators, <, >, <=, >=, and ==.
- In Java, Strings are immutable. That means they can't be changed. You can create new Strings, and assign them to a variable, but you can't change an existing String.
- Don't be discouraged if you can't just type this in. This program was created entirely with methods and programming constructs that we have covered, but there are things you'll need to figure out to make it all work together. Be systematic, patient, and persistent. And have fun!
Submit Your Assignment
Submit Wheel.java to the to the HW4 dropbox on D2L.
[ Course Schedule ]
[ Syllabus ]