SlideShare a Scribd company logo
1 of 11
Assignment Specifications
You must implement a simplified version of hangman. In our
simplified version, the player gets 7 incorrect guesses to guess
all of the characters within a phrase. You are required to
implement the specified functions and utilize any provided
functions.
Hangman Algorithm
● Get phrase to be solved (using getline to allow for spaces
in the phrase to be guessed)
● Clear output window so phrase is not seen (clear window
using clearScreen())
● Setup unsolved phrase so game has another string with
dashes in place of characters
(call setupUnsolved function)
● Output the unsolved phrase
● Play Game until phrase is completely guessed or no wrong
guesses left, 7 wrong allowed
○ Get letter guess (call getGuess function)
(All user input & respective prompts after initial phrase should
ONLY occur
in the getGuess function)
○ Update string containing all characters guessed so far
○ Take action on the guess
■ Correct: update unsolved phrase using the updateUnsolved
function
■ Incorrect: update the wrong guess count
○ Clear the screen, using clearScreen()
○ Output game status
■ updated unsolved phrase - phrase with dashes for
unguessed letters
■ list of characters guessed so far
■ number of wrong guesses left
● Output game over message (You lost! or
Congratulations!!)
Header File
We have supplied a header file to be utilized with this
assignment. The file name is assn.h. In the file is a function
that will clear the terminal window. You will call this function
to clear the screen in the specified spots within the algorithm.
You should include the header file at the top of your assignment
with the other includes (this one should be last): #include
“assn.h”
Additional Requirements and Hints
● Implement each function and get feedback/credit for each
before doing main game
● All user input statements should be followed by an output
statement to create a blank line.
● All inputs and corresponding prompts after initial phrase
occur only in body of getGuess
● All phrases and valid guesses will use lowercase
alphabetic characters
● The player gets 7 wrong guesses.
● No input or output statements exist in setupUnsolved or
updateUnsolved
● You should be utilizing a single puzzle variable and
assigning into it the return value from setupUnsolved and
updateUnsolved.
● Use at(): This member function can go on either side of an
‘=’ sign. To either get and use the value at a specified position
(right side) or to assign a new value into that specific position
(left side). at() throws an exception when you access an invalid
value, this will save you time hunting down bugs. Do not use []
syntax as it may or may not throw an error.
● bool isalpha(char): In order to check to see if a guess is
proper alphabetic character you can use this built in function
that takes a single character as an argument.
● Note: The functions setupUnsolved and updateUnsolved
act in opposition to each other. This means that should have
slight logical differences but are coded similarly.
Functions
The following 3 functions are required.
You must define, implement and correctly use these 3 functions
with the exact specifications described below. In fact, just copy-
and-paste these comments and function headers into your source
file one-by-one as you implement them.
/// @brief Puts dashes in place of alphabetic characters in the
phrase.
/// @param phrase the phrase to be solved
/// @return the phrase with all alphabetic characters converted
to dashes
string setupUnsolved(string phrase)
/// @brief Replaces the dashes with the guessed character.
/// @param phrase the phrase to be solved
/// @param unsolved the phrase with dashes for all unsolved
characters
/// @param guess the char containing the current guessed
character
/// @return the new unsolved string with dashes replaced by
new guess
string updateUnsolved(string phrase, string unsolved, char
guess)
/// @brief Gets valid guess as input.
///
/// A guess is taken as input as a character. It is valid if
/// 1) it is an alphabetic character and
/// 2) the character has not already been guessed
///
/// @param prevGuesses the string containing all characters
guessed so far
/// @return a valid guess and only a valid guess as a character
char getGuess(string prevGuesses)
Reading diff Output
Due to the possibility of an excess amount of output we simply
show the differences between the solution’s output and the
output of the program that is being tested; whether it is output
specific to a function or the whole program’s output. The
following explains how to read this difference output.
--- hangman.cpp
+++ solution.cpp
@@ -56,2 +56,2 @@
wrong guesses left: 0
-you lost
+you lost!
The first 2 lines are a key, they show the symbol associated
with with the listed file. The lines after the @@ sybmols show
differences. The first character in every line states which file it
comes from. If no symbol character (“+” or “-”) is shown then
it occurs in both files.
In order to fix your output you should change all lines that do
not match the solution.
Specific to the above:
The - symbol is associated with the file named hangman.cpp
The + symbol is associated with the file named solution.cpp
The line “wrong guesses left” has no initial symbol, it occurs in
both files.
The line “-you lost” has a minus sign as an initial symbol, it
occurs in hangman.cpp.
The line “+you lost” has a plus sign as an initial symbol, it
occurs in solution.cpp.
To fix the above example, the hangman.cpp is missing an
exclamation mark; if we add it then the output will match and
this specific case will disappear.
Example Run (user input has been bolded and underlined for
emphasis, c by itself is clearScreen output)
Enter phrase: hello.
c
Phrase: -----.
Enter a guess: h
c
Phrase: h----.
Guessed so far: h
Wrong guesses left: 7
Enter a guess: e
c
Phrase: he---.
Guessed so far: he
Wrong guesses left: 7
Enter a guess: l
c
Phrase: hell-.
Guessed so far: hel
Wrong guesses left: 7
Enter a guess: d
c
Phrase: hell-.
Guessed so far: held
Wrong guesses left: 6
Enter a guess: l
Invalid guess! Please re-enter a guess: 8
Invalid guess! Please re-enter a guess: o
c
Phrase: hello.
Guessed so far: heldo
Wrong guesses left: 6
Congratulations!!

More Related Content

Similar to Assignment SpecificationsYou must implement a simplified version .docx

1 ECE 175 Computer Programming for Engineering Applica.docx
1  ECE 175 Computer Programming for Engineering Applica.docx1  ECE 175 Computer Programming for Engineering Applica.docx
1 ECE 175 Computer Programming for Engineering Applica.docx
oswald1horne84988
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
wilcockiris
 
Important notes· NOTE it is usually fine and often encouraged i.docx
Important notes· NOTE it is usually fine and often encouraged i.docxImportant notes· NOTE it is usually fine and often encouraged i.docx
Important notes· NOTE it is usually fine and often encouraged i.docx
wilcockiris
 
C++ code, please help! Troubleshooting and cannot for the life of me.pdf
C++ code, please help! Troubleshooting and cannot for the life of me.pdfC++ code, please help! Troubleshooting and cannot for the life of me.pdf
C++ code, please help! Troubleshooting and cannot for the life of me.pdf
rahulfancycorner21
 
C++ code, please help! RESPOND W COMPLETED CODE PLEASE, am using V.pdf
C++ code, please help! RESPOND W COMPLETED CODE PLEASE,  am using V.pdfC++ code, please help! RESPOND W COMPLETED CODE PLEASE,  am using V.pdf
C++ code, please help! RESPOND W COMPLETED CODE PLEASE, am using V.pdf
rahulfancycorner21
 
Project 2 MARIE Start code at bottom of document1. IntroductionT.docx
Project 2 MARIE Start code at bottom of document1. IntroductionT.docxProject 2 MARIE Start code at bottom of document1. IntroductionT.docx
Project 2 MARIE Start code at bottom of document1. IntroductionT.docx
briancrawford30935
 
CS 107 – Introduction to Computing and Programming – Spring 20.docx
CS 107 – Introduction to Computing and Programming – Spring 20.docxCS 107 – Introduction to Computing and Programming – Spring 20.docx
CS 107 – Introduction to Computing and Programming – Spring 20.docx
faithxdunce63732
 
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docxINPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
jaggernaoma
 

Similar to Assignment SpecificationsYou must implement a simplified version .docx (20)

Javascript
JavascriptJavascript
Javascript
 
03-fortran.ppt
03-fortran.ppt03-fortran.ppt
03-fortran.ppt
 
Ch09
Ch09Ch09
Ch09
 
Ecs 10 programming assignment 4 loopapalooza
Ecs 10 programming assignment 4   loopapaloozaEcs 10 programming assignment 4   loopapalooza
Ecs 10 programming assignment 4 loopapalooza
 
1 ECE 175 Computer Programming for Engineering Applica.docx
1  ECE 175 Computer Programming for Engineering Applica.docx1  ECE 175 Computer Programming for Engineering Applica.docx
1 ECE 175 Computer Programming for Engineering Applica.docx
 
05 c++-strings
05 c++-strings05 c++-strings
05 c++-strings
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
 
Important notes· NOTE it is usually fine and often encouraged i.docx
Important notes· NOTE it is usually fine and often encouraged i.docxImportant notes· NOTE it is usually fine and often encouraged i.docx
Important notes· NOTE it is usually fine and often encouraged i.docx
 
Python-Cheat-Sheet.pdf
Python-Cheat-Sheet.pdfPython-Cheat-Sheet.pdf
Python-Cheat-Sheet.pdf
 
C++ code, please help! Troubleshooting and cannot for the life of me.pdf
C++ code, please help! Troubleshooting and cannot for the life of me.pdfC++ code, please help! Troubleshooting and cannot for the life of me.pdf
C++ code, please help! Troubleshooting and cannot for the life of me.pdf
 
Getting started in c++
Getting started in c++Getting started in c++
Getting started in c++
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and strings
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and strings
 
Control structures pyhton
Control structures  pyhtonControl structures  pyhton
Control structures pyhton
 
C++ code, please help! RESPOND W COMPLETED CODE PLEASE, am using V.pdf
C++ code, please help! RESPOND W COMPLETED CODE PLEASE,  am using V.pdfC++ code, please help! RESPOND W COMPLETED CODE PLEASE,  am using V.pdf
C++ code, please help! RESPOND W COMPLETED CODE PLEASE, am using V.pdf
 
Project 2 MARIE Start code at bottom of document1. IntroductionT.docx
Project 2 MARIE Start code at bottom of document1. IntroductionT.docxProject 2 MARIE Start code at bottom of document1. IntroductionT.docx
Project 2 MARIE Start code at bottom of document1. IntroductionT.docx
 
CS 107 – Introduction to Computing and Programming – Spring 20.docx
CS 107 – Introduction to Computing and Programming – Spring 20.docxCS 107 – Introduction to Computing and Programming – Spring 20.docx
CS 107 – Introduction to Computing and Programming – Spring 20.docx
 
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docxINPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
 
Php Learning show
Php Learning showPhp Learning show
Php Learning show
 
Pythonintro
PythonintroPythonintro
Pythonintro
 

More from lynettearnold46882

Assignment User FrustrationThe quality of the user experience i.docx
Assignment User FrustrationThe quality of the user experience i.docxAssignment User FrustrationThe quality of the user experience i.docx
Assignment User FrustrationThe quality of the user experience i.docx
lynettearnold46882
 
Assignment Upstream Approaches to Canadian Population HealthAlt.docx
Assignment Upstream Approaches to Canadian Population HealthAlt.docxAssignment Upstream Approaches to Canadian Population HealthAlt.docx
Assignment Upstream Approaches to Canadian Population HealthAlt.docx
lynettearnold46882
 
Assignment Type up an essay on one of two prompts and submit the .docx
Assignment Type up an essay on one of two prompts and submit the .docxAssignment Type up an essay on one of two prompts and submit the .docx
Assignment Type up an essay on one of two prompts and submit the .docx
lynettearnold46882
 
Assignment Two UNIT 2Student Name _______________________.docx
Assignment Two UNIT 2Student Name _______________________.docxAssignment Two UNIT 2Student Name _______________________.docx
Assignment Two UNIT 2Student Name _______________________.docx
lynettearnold46882
 
Assignment Two Objectives • Understand how the.docx
Assignment Two   Objectives • Understand how the.docxAssignment Two   Objectives • Understand how the.docx
Assignment Two Objectives • Understand how the.docx
lynettearnold46882
 
Assignment Topic Exploration and Analysis (Proposal)In Week 6 o.docx
Assignment Topic Exploration and Analysis (Proposal)In Week 6 o.docxAssignment Topic Exploration and Analysis (Proposal)In Week 6 o.docx
Assignment Topic Exploration and Analysis (Proposal)In Week 6 o.docx
lynettearnold46882
 
Assignment To consider three sources about the Fall of Rome and w.docx
Assignment To consider three sources about the Fall of Rome and w.docxAssignment To consider three sources about the Fall of Rome and w.docx
Assignment To consider three sources about the Fall of Rome and w.docx
lynettearnold46882
 
Assignment topic Rapid Influenza Testing in Children and Adult.docx
Assignment topic  Rapid Influenza Testing in Children and Adult.docxAssignment topic  Rapid Influenza Testing in Children and Adult.docx
Assignment topic Rapid Influenza Testing in Children and Adult.docx
lynettearnold46882
 
Assignment Topic 1Choose a contemporary painting, sculpture, o.docx
Assignment Topic 1Choose a contemporary painting, sculpture, o.docxAssignment Topic 1Choose a contemporary painting, sculpture, o.docx
Assignment Topic 1Choose a contemporary painting, sculpture, o.docx
lynettearnold46882
 
Assignment TitleAssessment Item 03 Case Study Analysis – Engagi.docx
Assignment TitleAssessment Item 03 Case Study Analysis – Engagi.docxAssignment TitleAssessment Item 03 Case Study Analysis – Engagi.docx
Assignment TitleAssessment Item 03 Case Study Analysis – Engagi.docx
lynettearnold46882
 
Assignment Three Technical Descriptions Due March 2 (1155 PM .docx
Assignment Three Technical Descriptions Due March 2 (1155 PM .docxAssignment Three Technical Descriptions Due March 2 (1155 PM .docx
Assignment Three Technical Descriptions Due March 2 (1155 PM .docx
lynettearnold46882
 
Assignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docx
Assignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docxAssignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docx
Assignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docx
lynettearnold46882
 
Assignment title An Evaluation of the Business Strategy at Mc D.docx
Assignment title An Evaluation of the Business Strategy at Mc D.docxAssignment title An Evaluation of the Business Strategy at Mc D.docx
Assignment title An Evaluation of the Business Strategy at Mc D.docx
lynettearnold46882
 
Assignment Three Case study report – mixed mediaValue 40 .docx
Assignment Three Case study report – mixed mediaValue 40 .docxAssignment Three Case study report – mixed mediaValue 40 .docx
Assignment Three Case study report – mixed mediaValue 40 .docx
lynettearnold46882
 
Assignment The Nurse Leader as Knowledge WorkerThe term kn.docx
Assignment The Nurse Leader as Knowledge WorkerThe term kn.docxAssignment The Nurse Leader as Knowledge WorkerThe term kn.docx
Assignment The Nurse Leader as Knowledge WorkerThe term kn.docx
lynettearnold46882
 

More from lynettearnold46882 (20)

Assignment User FrustrationThe quality of the user experience i.docx
Assignment User FrustrationThe quality of the user experience i.docxAssignment User FrustrationThe quality of the user experience i.docx
Assignment User FrustrationThe quality of the user experience i.docx
 
Assignment Upstream Approaches to Canadian Population HealthAlt.docx
Assignment Upstream Approaches to Canadian Population HealthAlt.docxAssignment Upstream Approaches to Canadian Population HealthAlt.docx
Assignment Upstream Approaches to Canadian Population HealthAlt.docx
 
Assignment Type up an essay on one of two prompts and submit the .docx
Assignment Type up an essay on one of two prompts and submit the .docxAssignment Type up an essay on one of two prompts and submit the .docx
Assignment Type up an essay on one of two prompts and submit the .docx
 
Assignment TypeIndividual ProjectDeliverable Length8–10 slid.docx
Assignment TypeIndividual ProjectDeliverable Length8–10 slid.docxAssignment TypeIndividual ProjectDeliverable Length8–10 slid.docx
Assignment TypeIndividual ProjectDeliverable Length8–10 slid.docx
 
Assignment Type Individual discussion Board;   450 – 550 word.docx
Assignment Type Individual discussion Board;   450 – 550 word.docxAssignment Type Individual discussion Board;   450 – 550 word.docx
Assignment Type Individual discussion Board;   450 – 550 word.docx
 
Assignment Two UNIT 2Student Name _______________________.docx
Assignment Two UNIT 2Student Name _______________________.docxAssignment Two UNIT 2Student Name _______________________.docx
Assignment Two UNIT 2Student Name _______________________.docx
 
Assignment Two Select a college or university and provide th.docx
Assignment Two Select a college or university and provide th.docxAssignment Two Select a college or university and provide th.docx
Assignment Two Select a college or university and provide th.docx
 
Assignment Two Objectives • Understand how the.docx
Assignment Two   Objectives • Understand how the.docxAssignment Two   Objectives • Understand how the.docx
Assignment Two Objectives • Understand how the.docx
 
Assignment Topic Exploration and Analysis (Proposal)In Week 6 o.docx
Assignment Topic Exploration and Analysis (Proposal)In Week 6 o.docxAssignment Topic Exploration and Analysis (Proposal)In Week 6 o.docx
Assignment Topic Exploration and Analysis (Proposal)In Week 6 o.docx
 
Assignment To consider three sources about the Fall of Rome and w.docx
Assignment To consider three sources about the Fall of Rome and w.docxAssignment To consider three sources about the Fall of Rome and w.docx
Assignment To consider three sources about the Fall of Rome and w.docx
 
Assignment topic Rapid Influenza Testing in Children and Adult.docx
Assignment topic  Rapid Influenza Testing in Children and Adult.docxAssignment topic  Rapid Influenza Testing in Children and Adult.docx
Assignment topic Rapid Influenza Testing in Children and Adult.docx
 
Assignment Topic 1Choose a contemporary painting, sculpture, o.docx
Assignment Topic 1Choose a contemporary painting, sculpture, o.docxAssignment Topic 1Choose a contemporary painting, sculpture, o.docx
Assignment Topic 1Choose a contemporary painting, sculpture, o.docx
 
Assignment TitleAssessment Item 03 Case Study Analysis – Engagi.docx
Assignment TitleAssessment Item 03 Case Study Analysis – Engagi.docxAssignment TitleAssessment Item 03 Case Study Analysis – Engagi.docx
Assignment TitleAssessment Item 03 Case Study Analysis – Engagi.docx
 
Assignment Title Knowledge management cycle process in or.docx
Assignment Title Knowledge management cycle process in or.docxAssignment Title Knowledge management cycle process in or.docx
Assignment Title Knowledge management cycle process in or.docx
 
Assignment Three Technical Descriptions Due March 2 (1155 PM .docx
Assignment Three Technical Descriptions Due March 2 (1155 PM .docxAssignment Three Technical Descriptions Due March 2 (1155 PM .docx
Assignment Three Technical Descriptions Due March 2 (1155 PM .docx
 
Assignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docx
Assignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docxAssignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docx
Assignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docx
 
Assignment title An Evaluation of the Business Strategy at Mc D.docx
Assignment title An Evaluation of the Business Strategy at Mc D.docxAssignment title An Evaluation of the Business Strategy at Mc D.docx
Assignment title An Evaluation of the Business Strategy at Mc D.docx
 
ASSIGNMENT The student will submit a research project that compares.docx
ASSIGNMENT The student will submit a research project that compares.docxASSIGNMENT The student will submit a research project that compares.docx
ASSIGNMENT The student will submit a research project that compares.docx
 
Assignment Three Case study report – mixed mediaValue 40 .docx
Assignment Three Case study report – mixed mediaValue 40 .docxAssignment Three Case study report – mixed mediaValue 40 .docx
Assignment Three Case study report – mixed mediaValue 40 .docx
 
Assignment The Nurse Leader as Knowledge WorkerThe term kn.docx
Assignment The Nurse Leader as Knowledge WorkerThe term kn.docxAssignment The Nurse Leader as Knowledge WorkerThe term kn.docx
Assignment The Nurse Leader as Knowledge WorkerThe term kn.docx
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 

Recently uploaded (20)

NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 

Assignment SpecificationsYou must implement a simplified version .docx

  • 1. Assignment Specifications You must implement a simplified version of hangman. In our simplified version, the player gets 7 incorrect guesses to guess all of the characters within a phrase. You are required to implement the specified functions and utilize any provided functions. Hangman Algorithm ● Get phrase to be solved (using getline to allow for spaces in the phrase to be guessed) ● Clear output window so phrase is not seen (clear window using clearScreen()) ● Setup unsolved phrase so game has another string with dashes in place of characters (call setupUnsolved function) ● Output the unsolved phrase ● Play Game until phrase is completely guessed or no wrong guesses left, 7 wrong allowed ○ Get letter guess (call getGuess function) (All user input & respective prompts after initial phrase should ONLY occur in the getGuess function)
  • 2. ○ Update string containing all characters guessed so far ○ Take action on the guess ■ Correct: update unsolved phrase using the updateUnsolved function ■ Incorrect: update the wrong guess count ○ Clear the screen, using clearScreen() ○ Output game status ■ updated unsolved phrase - phrase with dashes for unguessed letters ■ list of characters guessed so far ■ number of wrong guesses left ● Output game over message (You lost! or Congratulations!!) Header File We have supplied a header file to be utilized with this assignment. The file name is assn.h. In the file is a function that will clear the terminal window. You will call this function to clear the screen in the specified spots within the algorithm. You should include the header file at the top of your assignment with the other includes (this one should be last): #include “assn.h”
  • 3. Additional Requirements and Hints ● Implement each function and get feedback/credit for each before doing main game ● All user input statements should be followed by an output statement to create a blank line. ● All inputs and corresponding prompts after initial phrase occur only in body of getGuess ● All phrases and valid guesses will use lowercase alphabetic characters ● The player gets 7 wrong guesses. ● No input or output statements exist in setupUnsolved or updateUnsolved ● You should be utilizing a single puzzle variable and assigning into it the return value from setupUnsolved and updateUnsolved. ● Use at(): This member function can go on either side of an ‘=’ sign. To either get and use the value at a specified position (right side) or to assign a new value into that specific position (left side). at() throws an exception when you access an invalid value, this will save you time hunting down bugs. Do not use [] syntax as it may or may not throw an error. ● bool isalpha(char): In order to check to see if a guess is proper alphabetic character you can use this built in function that takes a single character as an argument.
  • 4. ● Note: The functions setupUnsolved and updateUnsolved act in opposition to each other. This means that should have slight logical differences but are coded similarly. Functions The following 3 functions are required. You must define, implement and correctly use these 3 functions with the exact specifications described below. In fact, just copy- and-paste these comments and function headers into your source file one-by-one as you implement them. /// @brief Puts dashes in place of alphabetic characters in the phrase. /// @param phrase the phrase to be solved /// @return the phrase with all alphabetic characters converted to dashes string setupUnsolved(string phrase) /// @brief Replaces the dashes with the guessed character.
  • 5. /// @param phrase the phrase to be solved /// @param unsolved the phrase with dashes for all unsolved characters /// @param guess the char containing the current guessed character /// @return the new unsolved string with dashes replaced by new guess string updateUnsolved(string phrase, string unsolved, char guess) /// @brief Gets valid guess as input. /// /// A guess is taken as input as a character. It is valid if /// 1) it is an alphabetic character and /// 2) the character has not already been guessed /// /// @param prevGuesses the string containing all characters guessed so far /// @return a valid guess and only a valid guess as a character char getGuess(string prevGuesses)
  • 6. Reading diff Output Due to the possibility of an excess amount of output we simply show the differences between the solution’s output and the output of the program that is being tested; whether it is output specific to a function or the whole program’s output. The following explains how to read this difference output. --- hangman.cpp +++ solution.cpp @@ -56,2 +56,2 @@ wrong guesses left: 0 -you lost +you lost! The first 2 lines are a key, they show the symbol associated with with the listed file. The lines after the @@ sybmols show differences. The first character in every line states which file it comes from. If no symbol character (“+” or “-”) is shown then it occurs in both files.
  • 7. In order to fix your output you should change all lines that do not match the solution. Specific to the above: The - symbol is associated with the file named hangman.cpp The + symbol is associated with the file named solution.cpp The line “wrong guesses left” has no initial symbol, it occurs in both files. The line “-you lost” has a minus sign as an initial symbol, it occurs in hangman.cpp. The line “+you lost” has a plus sign as an initial symbol, it occurs in solution.cpp. To fix the above example, the hangman.cpp is missing an exclamation mark; if we add it then the output will match and this specific case will disappear. Example Run (user input has been bolded and underlined for emphasis, c by itself is clearScreen output) Enter phrase: hello.
  • 8. c Phrase: -----. Enter a guess: h c Phrase: h----. Guessed so far: h Wrong guesses left: 7 Enter a guess: e c
  • 9. Phrase: he---. Guessed so far: he Wrong guesses left: 7 Enter a guess: l c Phrase: hell-. Guessed so far: hel Wrong guesses left: 7 Enter a guess: d c
  • 10. Phrase: hell-. Guessed so far: held Wrong guesses left: 6 Enter a guess: l Invalid guess! Please re-enter a guess: 8 Invalid guess! Please re-enter a guess: o c Phrase: hello. Guessed so far: heldo Wrong guesses left: 6