22a. Hangman Key Handler
Every keypress is a guess - adjust the model accordingly.
The key handler needs to change the model depending on what key was typed.
-
Create an example model for some state in the game. You could use one of your examples from the initial planning.
-
Write a check-expect that demonstrates what should happen when the person hits a key which is in the word.
-
Write a check-expect that demonstrates what should happen when the person hits a key which is not in the word.
-
Seriously!! Write check-expects. See my example checks for the key handler.
-
Recommendation: Write the helper function
(string-contains-letter? str letter)
that determines if a letter is in the word. -
Write the key handler.