CMSC 201 |
Homework 8 - Due 11/14This homework must be submitted by 5pm on the due date to get any credit. For HW8, you will write a simple 2 player word guessing game. The purpose of this homework is for you to use the top-down design skills that you have learned in lecture to create a well modularized program. Your main can be up to 50 lines of code (the less the better) and you need to have at least 8 functions (you can have more). Each function should perform a well-defined task (e.g. open the file, print out the score, print out who won the game, etc.). Take time to draw a top-down design diagram and write some pseudocode instead of going straight to the computer. Once you have a good design, start to code. Here is how the game will work:
Sample run 1bash-4.1$ cat wordFile1.txt book bash-4.1$ python hw8.py Enter the name of your word file: wordFile1.txt Round: 1 _ _ _ _ Player 1's turn ---------------- The Score for Player 1 is: 0 The Score for Player 2 is: 0 ---------------- Enter a letter: b B _ _ _ Player 1's turn ---------------- The Score for Player 1 is: 1 The Score for Player 2 is: 0 ---------------- Enter a letter: a No letter: A in the word B _ _ _ Player 2's turn ---------------- The Score for Player 1 is: 1 The Score for Player 2 is: 0 ---------------- Enter a letter: o B O O _ Player 2's turn ---------------- The Score for Player 1 is: 1 The Score for Player 2 is: 2 ---------------- Enter a letter: q No letter: Q in the word B O O _ Player 1's turn ---------------- The Score for Player 1 is: 1 The Score for Player 2 is: 2 ---------------- Enter a letter: k B O O K THE FINAL SCORE IS: ---------------- The Score for Player 1 is: 2 The Score for Player 2 is: 2 ---------------- The game is a draw Sample Run 2bash-4.1$ cat wordFile.txt UMBC python bash-4.1$ python hw8.py Enter the name of your word file: wordFile.txt Round: 1 _ _ _ _ Player 1's turn ---------------- The Score for Player 1 is: 0 The Score for Player 2 is: 0 ---------------- Enter a letter: s No letter: S in the word _ _ _ _ Player 2's turn ---------------- The Score for Player 1 is: 0 The Score for Player 2 is: 0 ---------------- Enter a letter: T No letter: T in the word _ _ _ _ Player 1's turn ---------------- The Score for Player 1 is: 0 The Score for Player 2 is: 0 ---------------- Enter a letter: m _ M _ _ Player 1's turn ---------------- The Score for Player 1 is: 1 The Score for Player 2 is: 0 ---------------- Enter a letter: S The letter S has already been selected _ M _ _ Player 2's turn ---------------- The Score for Player 1 is: 0 The Score for Player 2 is: 0 ---------------- Enter a letter: cat Enter a letter: 4 Enter a letter: c _ M _ C Player 2's turn ---------------- The Score for Player 1 is: 0 The Score for Player 2 is: 1 ---------------- Enter a letter: b _ M B C Player 2's turn ---------------- The Score for Player 1 is: 0 The Score for Player 2 is: 2 ---------------- Enter a letter: a No letter: A in the word _ M B C Player 1's turn ---------------- The Score for Player 1 is: 0 The Score for Player 2 is: 2 ---------------- Enter a letter: u U M B C Round: 2 _ _ _ _ _ _ Player 1's turn ---------------- The Score for Player 1 is: 1 The Score for Player 2 is: 2 ---------------- Enter a letter: s No letter: S in the word _ _ _ _ _ _ Player 2's turn ---------------- The Score for Player 1 is: 1 The Score for Player 2 is: 2 ---------------- Enter a letter: t _ _ T _ _ _ Player 2's turn ---------------- The Score for Player 1 is: 1 The Score for Player 2 is: 3 ---------------- Enter a letter: p P _ T _ _ _ Player 2's turn ---------------- The Score for Player 1 is: 1 The Score for Player 2 is: 4 ---------------- Enter a letter: n P _ T _ _ N Player 2's turn ---------------- The Score for Player 1 is: 1 The Score for Player 2 is: 5 ---------------- Enter a letter: a No letter: A in the word P _ T _ _ N Player 1's turn ---------------- The Score for Player 1 is: 1 The Score for Player 2 is: 5 ---------------- Enter a letter: y P Y T _ _ N Player 1's turn ---------------- The Score for Player 1 is: 2 The Score for Player 2 is: 5 ---------------- Enter a letter: $ Enter a letter: h P Y T H _ N Player 1's turn ---------------- The Score for Player 1 is: 3 The Score for Player 2 is: 5 ---------------- Enter a letter: q No letter: Q in the word P Y T H _ N Player 2's turn ---------------- The Score for Player 1 is: 3 The Score for Player 2 is: 5 ---------------- Enter a letter: Y The letter Y has already been selected P Y T H _ N Player 1's turn ---------------- The Score for Player 1 is: 3 The Score for Player 2 is: 4 ---------------- Enter a letter: a The letter A has already been selected P Y T H _ N Player 2's turn ---------------- The Score for Player 1 is: 2 The Score for Player 2 is: 4 ---------------- Enter a letter: o P Y T H O N THE FINAL SCORE IS: ---------------- The Score for Player 1 is: 2 The Score for Player 2 is: 5 ---------------- Player 2 WINS! When you've finished your homework, use the submit command to submit the file. You must be logged into your account and you must be in the same directory as the file you're trying to submit. At the Linux prompt, type submit cs201 HW8 hw8.pyAfter entering the submit command shown above, you should get a confirmation that submit worked correctly: Submitting hw8.py...OKIf not, check your spelling and that you have included each of the required parts and try again. You can check your submission by entering: submitls cs201 HW8You should see the name of the file that you just submitted, in this case hw8.py v |
Adapted from UMBC CSHC's webpage design |