CSCI 261 - Programming Concepts

Fall 2018 - A5 - Hangman

Quick Links: Canvas | Mines | Piazza | zyBooks

|   Home |  Contact |  Syllabus |  Assignments |  Schedule |  Resources   |

This assignment is due by Thursday, October 18, 2018 11:59 PM.

· Instructions · Rubric · Submission ·


This assignment exercises your ability to use conditionals, loops, arrays, and functions together.


Instructions



Your goal for this assignment is to create a playable Hangman game. You will need to create a secret word for the user to try and guess one letter at a time.

First you need to ask the user to enter a letter. Then you'll check if that letter exists in your secret word. If it does exist, then you should tell the user and display the puzzle with the letter revealed. If the letter does not exist, then inform the user that the letter is not found. You will repeat this process until all the correct letters have been guessed or the user has entered 7 wrong letters.

Hopefully it is readily clear that you will need to use a loop to keep prompting the user to enter a letter. You will also need to use conditionals to check if the letter exists. You will need to use an array to store the secret letters (since a word is just a collection of letters). We'll also need arrays to keep track of the previously guessed letters (we don't want the player to guess wrong a second time) and the solved letters.

An example of a winning game:

Welcome to Hangman!!

Take a guess: _ _ _ _ _ _ _ _ _ _ _
Your guess: a
There's a A!

Take a guess: _ _ _ _ _ A _ _ _ _ _
Your guess: c
Sorry, no C's. You have 6 wrong guesses remaining.

Take a guess: _ _ _ _ _ A _ _ _ _ _
Your guess: a
You already guessed A.

...

Take a guess: P R O _ R A M M I N _
Your guess: g
There's a G!
CONGRATS! You solved the puzzle: P R O G R A M M I N G

An example of a losing game:

Welcome to Hangman!!

Take a guess: _ _ _ _ _ _ _ _ _ _ _
Your guess: a
There's a A!

Take a guess: _ _ _ _ _ A _ _ _ _ _
Your guess: c
Sorry, no C's. You have 6 wrong guesses remaining.

Take a guess: _ _ _ _ _ A _ _ _ _ _
Your guess: q
Sorry, no Q's. You have 5 wrong guesses remaining.

Take a guess: _ _ _ _ _ A _ _ _ _ _
Your guess: a
You already guessed A. Pick again.

Take a guess: _ _ _ _ _ A _ _ _ _ _
Your guess: q
You already guessed Q. Pick again.

...

Take a guess: _ _ _ _ _ A _ _ _ _ _
Your guess: w
Sorry, no W's. You have 1 wrong guess remaining.

Take a guess: _ _ _ _ _ A _ _ _ _ _
Your guess: X
Sorry, no X's.
You lose. Try again!


Hints



  • You are going to need to use multiple arrays. These arrays correspond to:
    1. The secret word that is being guessed.
    2. The "current board" of letters the user has found.
    3. The list of letters the user has already guessed.
    Think about what is the most appropriate type for each array. They may not all be of type char depending on your implementation.

  • You'll need loops in multiple places:
    1. Continue asking the user for letters until solved or out of guesses
    2. Printing the current puzzle
    3. Checking if the letter exists in the puzzle
    4. Checking if the puzzle is solved


Functional Requirements



  • The user is allowed to guess using upper or lower case letters.
  • The user cannot guess the same letter more than once. Alert the user if they already guessed a letter.
  • The user is allowed 7 wrong guesses before losing the game.
  • Your secret word must be at least 6 letters long. This secret word must be stored in an array - not a string.
  • You must use arrays - not vectors.
  • Create a function to print the current solved puzzle
  • Create a function to return true or false if the letter has been already guessed
  • Create a function to return true or false if the letter is in the secret word
  • Create a function to return true or false if the puzzle is solved
  • Function prototypes must be placed in a *.h file and the definitions in a corresponding *.cpp file.


Grading Rubric


Your submission will be graded according to the following rubric.

PointsRequirement Description
2 All code submitted properly.
6 All labs completed and submitted
2 User interaction matches examples above
7 Game is properly playable
8 Functional requirements above met.
2 (1) Comments used
(2) Coding style followed
(3) Appropriate variable names, constants, and data types used
(4) Instructions followed
27 Total Points

This assignment is due by Thursday, October 18, 2018 11:59 PM.


Submission


Always, always, ALWAYS update the header comments at the top of your main.cpp file. And if you ever get stuck, remember that there is LOTS of help available. The following instructions are copied from How to Submit Homework.


It is critical that you follow these steps when submitting homework.

If you do not follow these instructions, your assignment will receive a major deduction. Why all the fuss? Because we have several hundred of these assignments to grade, and we use computer tools to automate as much of the process as possible. If you deviate from these instructions, our grading tools will not work. And that makes us very unhappy. And when we're unhappy, we give penalties. Thus, make us happy.


Submission Instructions



Here are step-by-step instructions for submitting your homework properly:
  1. File and folder names are extremely important in this process. Please double-check carefully, to ensure things are named correctly.
    1. The top-level folder of your project must be named Set5
    2. Inside Set5, create 4 sub-folders that are required for this Set. The name of each sub-folder is defined in that Set (e.g. L5A, L5B, L5C, and A5).
    3. Copy your main.cpp , additional header & source files, plus the CMakeLists.txt file into the subdirectories of Set5 (steps 1-2), zip this Set5 folder (steps 3-4), and then submit the zipped file (steps 5-11) to Canvas.
    4. For example, when you zip/submit Set5, there will be 4 sub-folders called L5A, L5B, L5C, and A5 inside the Set5 folder, and each of these sub-folders will have a file called main.cpp, additional header & source files, plus the CMakeLists.txt file .

  2. Using Windows Explorer (not to be confused with Internet Explorer), find the file named "main.cpp" located inside the folder for the particular lab or homework assignment you will submit.

    STOP: Are you really sure you are viewing the correct assignment's folder?

  3. Now, for A5, right click on the main.cpp to copy the file. Then, return to the Set5/A5 folder and right click to paste the file. In other words, put a copy of your homework's main.cpp source code into the Set5/A5 folder. Repeat this for each additional header & source file you have with this assignment, plus CMakeLists.txt.

    Follow the same steps for L5A, to put a copy of your lab's main.cpp into the Set5/L5A folder. Repeat this process for Set5/L5B, Set5/L5C.

    STOP: Are you sure your Set5 folder now has all your code to submit?

  4. Now, right-click on the "Set5" folder.
    1. In the pop-up menu that opens, move the mouse "Send to..." and expand the sub-menu.
    2. In the sub-menu that opens, select "Compressed (zipped) folder".

    STOP: Are you really sure you are zipping a Set5 folder with sub-folders that each contain a main.cpp file in it?

  5. After the previous step, you should now see a "Set5.zip" file.

  6. Now visit the Canvas page for this course and click the "Assignments" button in the sidebar.

  7. Find Set5, click on it, find the "Submist Assignment" area, and then click the "Choose File" button.

  8. Find the "Set5.zip" file created earlier and click the "Open" button.

    STOP: Are you really sure you are selecting the right homework assignment? Are you double-sure?

  9. WAIT! There's one more super-important step. Click on the blue "Submit Assignment" button to submit your homework.

  10. No, really, make sure you click the "Submit Assignment" button to actually submit your homework. Clicking the "Choose File" button in the previous step kind of makes it feel like you're done, but you must click the Submit button as well! And you must allow the file time to upload before you turn off your computer!

  11. Canvas should say "Submitted!". Click "Submission Details" and you can download the zip file you just submitted. In other words, verify you submitted what you think you submitted!
In summary, you must zip the "Set5" folder and only the "Set5" folder, this zip folder must have several sub-folders, you must name all these folders correctly, you must submit the correct zip file for this homework, and you must click the "Submit Assignment" button. Not doing these steps is like bringing your homework to class but forgetting to hand it in. No concessions will be made for incorrectly submitted work. If you incorrectly submit your homework, we will not be able to give you full credit. And that makes us unhappy.


This assignment is due by Thursday, October 18, 2018 11:59 PM.

Last Updated: 09/28/18 23:12


Valid HTML 4.01 Strict Valid CSS! Level Triple-A conformance, W3C WAI Web Content Accessibility Guidelines 2.0