CS21 Lab 7: Top-Down Design: hangman program

Part 1 Due 2 November, Part 2 Due 9 November 2013

Run update21, if you haven't already, to create the cs21/labs/07 directory. Then cd into your cs21/labs/07 directory and create the python programs for lab 7 in this directory (handin21 looks for your lab 7 assignments in your cs21/labs/07 directory):

    $ update21
    $ cd cs21/labs/07
Your programs are graded on both correctness and style. Please review the comments regarding programming style on the main page. In particular, each function needs a comment.
Introduction

For this assignment, you will write a program that implements the hangman game (you can use the "apples falling from the tree" alternative if you want). The focus of this assignment is for you to practice using top-down design to construct your solution incrementally.

Hangman is a simple letter guessing game. The computer picks a word (from a file) and displays it with underscores replacing the letters. The user tries to figure out the word by guessing one letter at a time. The user loses if they guess too many incorrect letters.

This assignment will span two weeks. In the first week, you will be required to design your solution and implement minimalistic function stubs for your design. In the second week, you will finish implementing and testing your design.

For the design of a program in the first week, you should have:

Here is a simple example of a top-down design. Note: Once you have your top-level design done you need to run handin21 and send me an email that you have completed your top-level design. I will look at your design and email you with feedback on your design within 24-48 hours. The earlier you send me your design, the earlier you can continue working on your lab. I would suggest you wait to hear back from me before continuing on your program because if I suggest you do something differently, you may have to redo some of your code.
Examples

Here are two examples of how your hangman program should work.

Example 1
Example 2

Requirements
Helpful tips
Extensions

Extentions are not a required part of lab 7, but you may want to try adding some once you get the required part implemented and tested.

Note: if you implement one or more extra features, include in the comment at the top of your file a description of the extra feature(s) you added, and tell us how to test your feature if it is like one of the first three. If we need any special input files to test your extra feature, you should include those in your lab07 directory when you submit your solution.

Here are some fun extensions that you might want to add to your program:

  1. give the user a choice or word topics (harry potter, rock bands, sports teams, dog breeds)
  2. allow answers with more than one word (e.g., PERRY THE PLATYPUS)
  3. let the user choose the difficulty of the game (easy, medium, hard)
  4. add some ascii art to the program
         ________
         |/      |
         |      (_)
         |      \|/
         |       |
         |     _/ \_
         |
     ____|____
    
  5. use the graphics library to draw the hangman or tree of apples
  6. allow user to quit or solve the puzzle at any point in the game

Submit

Once you are satisfied with your programs, hand them in by typing handin21 at the unix prompt.

You may run handin21 as many times as you like, and only the most recent submission will be recorded. This is useful if you realize, after handing in some programs, that you'd like to make a few more changes to them.