Write c++ program of Wordle Reload by creating a wordleword text file. For this program you can
Question:
Write c++ program of Wordle Reload by creating a wordleword text file.
For this program you can choose either to play a three letter or five letter Wordle board game. The Wordle text file consist of sorted three and five letter words.
Indicators will be given if characters of the user-entered word are reflected in the guessed word. Example 3-letter word: fan
If the character is in the correct position, the character will display as an uppercase value.
Example:
Random word: fan
Guessed word: sad
Output: [ * ] [ A ] [ * ]
If the character is within the random word, the character will display as a lowercase value.
Example:
Random word: fan
Guessed word: net
Output: [ n ] [ * ] [ * ]
If you enter a character that is not in the word, an asterisk '*' will display.
Example:
Random word: fan
Guessed word: tic
Output: [ * ] [ * ] [ * ]
Starter Code, main.cpp
#include
#include
#include
#include
#include
#include
// Display name and program information
void displayIdentifyingInformation() {
cout << " \n"
<< "Program 3: Wordle Reload \n"
<< "CS 141, Spring 2022, UIC \n"
<< endl;
cout << "The objective of this game is to guess the randomly selected word within a given number of attempts. You can select either a three or five word board. \n"
<< "At the conclusion of the game, stats will be displayed. \n"
<< "Indicators will be given if characters of the user entered word are reflected in the guessed word. \n"
<< "- If the character is in the correct position, the character will display as an uppercase value. \n"
<< "- If the character is within the random word, the character will display as a lowercase value. \n"
<< "- If you enter a character that is not in the word, an asterisk '*' will display. \n"
<< endl;
}//end displayIdentifyingInformation()
void readWordsIntoWordlewords(
vector
char fileName[]) {
ifstream inStream;
inStream.open( fileName);
assert( inStream.fail() == false );
wordlewords.clear(); // Clear vector in case it already had some words in it
// Keep repeating while input from the file yields a word
string newWord; // Store a single input word
while( inStream >> newWord) { // While there is another word to be read
// Add this new word to the end of the vector, growing it in the process
wordlewords.push_back( newWord);
}
inStream.close(); // Close the wordlewords file
} //end readWordsIntoWordlewords()
int main() {
displayIdentifyingInformation;
int menuChoice;
vector
// Read in words from the wordlewords words files into vectors.
readWordsIntoWordlewords( wordlewords, "wordlewords.txt");
// Keep looping until user selects the option to exit
while( true) {
cout << endl
<< "Select a menu option:" << endl
<< " 1. To play Wordle Reload 3 letter play" << endl
<< " 2. To play Wordle Reload 5 letter play" << endl
<< " 3. Exit the program" << endl
<< "Your choice --> ";
cin >> menuChoice;
cout << endl;
// Dictionary will store commonly misspelled words
if( menuChoice == 1) {
cout << "To get started, enter your first 3 letter word." << endl;
cout << "You have 4 attempts to guess the random word." << endl;
cout << "The timer will start after your first word entry." << endl;
cout << "Try to guess the word within 20 seconds." << endl;
cout << endl;
cout << "Please enter word --> " << endl;
}
else if( menuChoice == 2) {
cout << "To get started, enter your first 5 letter word." << endl;
cout << "You have 6 attempts to guess the random word." << endl;
cout << "The timer will start after your first word entry." << endl;
cout << "Try to guess the word within 40 seconds." << endl;
cout << endl;
cout << "Please enter word --> " << endl;
} else if( menuChoice == 3) { // Exit if option 3 to exit was chosen
cout << "Overall Stats:" << endl;
cout << "- You guessed: " << endl;
cout << "- Your longest streak is: " << endl;
cout << "- Average word completion time: " << endl;
cout << "Exiting program" << endl;
break; // Break out of enclosing infinite game-play loop
}
} //end while( true)
return 0;
}//end main()
Output