The goal of this lab is to use the top-down design that you created last week to now do a bottom-up implementation of the game of Ghost. Each function should be unit tested as it is implemented.
Do an update21 to create the directory cs21/lab/07. Copy the design that you did last week to the current lab directory, and then change into that directory as shown below:
$ update21 $ cp cs21/lab/06/ghost.py cs21/lab/07 $ cd cs21/lab/07Edit the file ghost.py that is in the cs21/labs/07/ directory. The program handin21 will only look for files in this directory.
If you worked with a partner on the previous lab, you may continue
to work with the same partner on this lab. If you work with a
partner, be sure to put your name and the name of your partner in the
list of authors at the top of your program. Only one partner needs to
run
handin21 to submit the files for the group. Both partners
will receive the same grade.
You will implement a program that plays the word game Ghost using your top-down design as a starting point. Be sure to read carefully through all of the comments on your design from Lab 6 before you begin to construct your solution for Lab 7.
if __name__ == '__main__': main()
$ cd cs21/labs/07 $ python >>> from ghost import * >>> randomLetter() c >>> randomLetter() t >>> randomLetter() e
Notice in the following example that the user makes several mistakes, choosing an invalid menu option and failing to provide a valid letter. Your program should check for these errors and give the user a chance to try again.
Welcome to the game of Ghost. The current word fragment is: q 1. Add a letter 2. Challenge Choice: 3 Invalid choice, try again. 1. Add a letter 2. Challenge Choice: 1 Enter a letter: 5 Invalid letter, try again. Enter a letter: u The current word fragment is: qu Computer will add the letter: a The current word fragment is: qua 1. Add a letter 2. Challenge Choice: 1 Enter a letter: r The current word fragment is: quar Computer will add the letter: t Computer just made the word quart Congratulations, you just outsmarted the computer!
These suggestions are not required and should only be attempted when all of the required elements of the program are working.
Once you are satisfied with your program, hand it in by typing handin21 in a terminal window. include("../style/footer.php"); ?>