Develop the hangman game. The hangman game has a secret word that
the player tries to guess. The player guesses letters by pressing
keys on the keyboard. If the guessed letter is correct, it is
revealed on the screen. For example, suppose the secret word is
"guess" and the player presses the "s" key. The game should reveal
something like:
The player loses if seven incorrect guesses are made. The player
wins if the secret can be revealed with less than seven incorrect
guesses. The player should not be penalized for repeatedly guessing
the same incorrect letter.
The game should also reveal a "hangman" that shows the players
progress toward losing. Each wrong guess adds another body part to
the hangman. For example, if the user had guessed "t", "u", "s",
"q", "r", the game should look something like:
The hangman is complete when enough wrong guesses have been made:
Part 1:
Develop data definitions for binary trees of Symbols, and
binary trees of Numbers. The numbers and symbols should
occur at the leaf positions only.
Create two instances of each, and abstract over the data
definitions.
Design the function height
, which consumes any binary
tree and computes its height. That is, the maximum number of nodes
from the root of the given tree to a leaf. Here's some tests to
further explain:
(check-expect (height 5) 0)
(check-expect (height (make-node 'yes (make-node 'no 'maybe))) 2)
Part 2:
A leafy binary tree is a binary tree with the
symbol 'leaf
at its leafs.
Design a function that consumes a natural number n
and
creates (a list of) all leafy binary trees of height n
.
Hint: Design a function that consumes a natural
number n
and creates (a list of) all leafy binary
trees of height equal or less than n
.
Warning: this is not about
abstraction; it's just a reminder that more interesting (and
complex) programs are around the corner.