CS21 Lab 7: Top-Down Design: Scattergories

Top-Down Design due by midnight on Saturday, October 29
Full solution due by midnight on Saturday, November 5

Please read through the entire lab before starting! Also, as always, run update21 to create your cs21/labs/07 directory and create your programs for lab 7 in this directory.

Note that this is a two-part lab, split over two weeks. For this week, you will focus on using top-down design to create the overall structure of the program. Once your proposed structured has been reviewed and approved, you will use bottom-up implementation and unit testing to complete the full lab.

Scattergories

Our lab this week and next is to write a game similar to Scattergories. This is a word/categories game where the user is given a letter and twelve categories, and they try to write down a word or item that starts with the letter and matches each category.

For example, if the letter is "F", and the current twelve categories are:

1. Boys Names
2. Rivers
3. Animals
4. Things that are cold
5. Insects
6. TV Shows
7. Things that grow
8. Fruits
9. Things that are black
10. School Subjects
11. Movie Titles
12. Musical Instruments

you might write down "Frank" for #1, "Flintstones" for #6, and "Flute" for #12.

The goal is to write down one item for each category. Your program will use a time limit in which the user can answer as many categories possible. Once the time limit has passed, the program ends by displaying the final submission card. (Note: in the real game, multiple players all have the same list of categories and only unique answers are considered valid. We will model a single-player version instead).


For this lab you will use top-down design. We are giving you two weeks to complete this program. However, we require your initial top-down design due this Saturday (Oct 29) and the full implementation the following week (Nov 5). It is highly recommended that you submit your top-down design before the due date so that we can give you feedback before you start your implementation. See below for your design requirements.

Examples, Requirements, and Tips

Here are some examples of scattergories games to help you see how the program works:

You have some freedom in how you want your game to look. Here are our requirements for the game:

To validate input from the user, you may use the try/except example we did in class, as well as the in operator, or str methods. For example, isdigit() and isalpha() might be useful:

>>> word = "hello"
>>> nums = "1234"
>>> word.isalpha()
True
>>> word.isdigit()
False
>>> nums.isalpha()
False
>>> nums.isdigit()
True

The game timer can be implemented using the time() function. Here's an example of how it works:

>>> from time import *
>>> t1 = time()          # get current time
>>> x = 25               # do stuff here...
>>> print(x*5)
125
>>> t2 = time()          # get current time again
>>> print(t2 - t1)       # calculate elapsed time
18.1428039074

In the above example, it took me 18.1428 seconds to do the stuff between when the first time was recorded (t1) and the second time (t2). HINT: think about how you can accumulate total time and use that to end the program.

Top-down design requirements

You must complete, submit, and obtain feedback on your top-down design before beginning implementation. Special procedures for this two-week lab:

Please ensure you meet the following requirements before submitting your TDD. Remember, for the design of a program:

Here is a simple example of a top-down design.
And here is an example of a running scattergories top-down design. Your design doesn't have to match this exactly, but should allow the user to input some choices, and should show the (fake) game progress. This example does not have control flow prints (i.e., "in function X") to avoid revealing our actual design.

Extra Challenges

These do not affect your grade, so please only attempt them after completing the rest of your lab.



Submit

Once you are satisfied with your program, hand it in by typing handin21 in a terminal window.