Starting from:

$25

CS1570 -Assignment 02 - Solved

// Purpose: this file contains the main function of the program which // will input Fahrenheit temps from the user, then convert and // output the corresponding Celcius temperature. Wₒᵣd ₑ Fₒᵣ Fᵣᵢₑ d



Specifications
Your C++ program (all code can still be contained within the main function) should be designed to be played by two players instead of one. The main objective is still to have one of the players guess a five-letter word correctly. The program should first prompt Player 1 to enter “the word” for Player 2 to guess, after asking for their names of course. At the start of the program, it should also ask Player 1 to enter the friendship level, a higher value means a closer friendship bond with Player 2. Friendship level should have a range of value between 0 and 100, inclusive. If Player 1 inputs something outside of the acceptable range, then the program should keep prompting the player until a proper value is entered.

Just like the original Wordle game, Player 2 will have a maximum of six attempts to guess the word correctly. In each attempt, the program should prompt Player 2 to enter their word, and then see if the entered word matches with the key. If it’s an exact match, then the program should output a congratulations message so the two players can move onto their next friendship bonding activity. However, if it’s not a perfect match, then the program should provide some useful feedback as in the original game using the following notations:

●     Notation @.@ should be used if an input letter is not a part of the key

●     Notation ^( '-' )^ should be used if an input letter is a part of the key but is not in the right position

●     Notation ^o^ should be used if an input letter is a part of the key and is at the right position

For example, if the key word is “beard” and Player 2 entered “bound” as the first attempt, then the feedback provided should be:

You entered “BOUND”. Nice try, keep going!

B: ^o^

O: @.@

U: @.@

N: @.@

D: ^o^

The completion of all six attempts concludes a round. If Player 2 guessed the key word correctly, then the friendship level value should be correspondingly increased by the number of attempts Player 2 took to get to the correct word. Note that the maximum value friendship level can reach is 100. Next, the program should ask Player 1 if they want to begin a new round. If no, then the program will then keep asking Player 1 if they want to start a new round with a di erent Player 2. If Player 1 inputs no again, then the program will exit smoothly.

Additional Info
●     This program should trust no one. When prompting Player 1 for the key word, we need to check a couple things.

○ First, we need to ensure that the key word is a valid five-letter word (you may find this string function to be useful). If this constraint is violated, then the program should keep prompting Player 1 for the proper key word until one is entered.

○ Besides checking for the proper length of the key word, we also need to make sure that the key word is valid, i.e. each letter of the word is an alphabet. How do you do that? Well maybe this function can help you

(depending on your C++ compiler, you may need to include the <ctype.h> library).

■ But what if Player 1 input a word that is not an actual word that exists in the dictionary? Well, that’s the best we can do at this point, and checking for the meaning is outside of the scope of this assignment. Ten bonus points if you are able to come up with a good coding solution to address this issue. .

●     For this assignment, you may also find it to be useful to know how to manipulate (i.e. read/write) each letter in a string variable. One easy way to do that is through the use of the “at” function for the string data type. A sample usage is provided here:

#include <string> #include <iostream> using namespace std; int main(){ string str = “LAUGH”; // note: the first character in a string is // located at index position 0 (not 1) for(int index=0; index<str.length(); index++){ cout << str.at(index) << endl;

}

}

●     To make this assignment a bit easier for when you are checking if two words are an exact match, you can expect all of the input words from the players to be in uppercase. That is, you don’t have to perform input validation to check if the words contain any lowercase letters.

Sample Output
Coming soon…

More products