Navigation :
AP CS
Artificial Intelligence
Intermediate CS
-
3. Images
-
7. Numbers
-
8. Number Models
-
13. Booleans
-
15. Conditionals
-
20. Using Structures
-
Sem.I Review
-
21. Structures
-
22a. Recursion
-- 22a. Fibonacci
-- 22a. Digits
-- 22a. Sum Digits
-- 22a. Fibsum
-- 22a. More Recursion
-- 22a. Harmonic
-- 22a. Practice++
-- 22a. ss3
-- 22a. Recursive Helpers
-- 22a. Recursion Quiz Practice
-- 22a. Recursion Quiz 2018
-- 22a. Recursion Practice I 2019
-- Roygbiv Code
-- 22a. Strings
-- 22a. Helpers
-- 22a. Helpers: Count Divisors
-- 22a. Recursion Practice 3
-- 22a. Recursion Self Quiz
-- 22a. Recursion Practice 4
-- 22a. Mini-Quiz
-- 22a. Recursion Quiz 2
-- 22a. Recursion Practice 5
-- 22a. Recursion Practice 6
-- Quiz 3 (Hard)
-- Quiz 4 (Medium)
--
22a. Hangman Project
--- 22a. Hangman Outline
--- 22a. Hangman Images
--- 22a. Hangman Key Handler
--- 22a. Hangman DH Warmup
--- 22a. Hangman Draw Handler
-
22b. Lists
-
Sem.II Review
-
Typed Racket
-
Resources
-
Pro Features
- Online Help
Robotics
WY Robotics
Exploring CS (Teachers)
Resources
22a. Hangman Draw Handler
Draw the whole scene by using helper functions to draw the different
parts. At first you can just put all of the images above
each other;
later you can change the placement so it looks the way you prefer.
Draw the gallows based on how many wrong answers.
Draw the mistaken letters.
Draw the word with underscores for letters that are not guessed.
The key step is to draw the word with underscores for the letters missed.
underscorizer: string(word) string(letters-guessed) -> string
(check-expect (underscorizer "wow" "w") "w_w")
(check-expect (underscorizer "wow" "ow") "wow")
Of course you can take in the correct guesses instead of all guesses,
or you can take in anything else from your model that makes sense.
Advice
Decide on an approach:
Examine word letter by letter?
Examine letters guessed letter by letter?
Write tests that build up to your solution in the way we have
discussed and demonstrated in class.
Many approaches work. If you have no preference, I recommend the first
approach.