Homework: Ruby Scramble

Purpose

Preparation

Lesson

For this assignment you’ll create another simple word game. As shown in the figure below, when you start Scramble the first word will appear with the letters in random order (i.e., scrambled). The user guesses the word, and a message displays to indicate whether it is correct. The user may then continue or quit.

Unlike the Hangman game, the words in this game will be presented in order, not randomly. The specific order doesn’t matter (e.g., you can do it in the order read from the file, or sorted, etc.). The point is to overload and use the [] operator to access the words (i.e., if you have an object of type Words named words, you can access as words[0], words[1], etc.).

The game ends when the user chooses not to continue or when the end of the list of words is reached (an appropriate message should be displayed).

Sample execution:

Scrambled word: plape

What's the word?
apple
That is correct!

Continue? (Y/N)
y
Scrambled word: nnabaa

What's the word?
naanab
Sorry, that's not correct.

Continue? (Y/N)
n

Extra Requirements:

Rubric

This lesson is worth 18 points.

Points Metric
2 Initialize a Words object
2 Overload the [] operator in the Words class (but in the Scramble file)
5 Display a scrambled word
2 Access words in order using []
4 Allow the user to continue or quit
3 Appropriate messages for correct guess, incorrect guess, and reaching the end of the list of words

Submit

For simplicity of grading, please:

Zip your .rb files (new scramble + original words) and .txt files and submit on Canvas.