Question: make sure to use the SAME framework as in the base code PLS Using C + + create a replica of Wordle Word Selection: Each

make sure to use the SAME framework as in the base code PLS
Using C++create a replica of Wordle
Word Selection: Each time the user plays, a new word should be selected at random from a list of words stored in a file "words.txt".The words should be different each time the user plays, ensuring variety.
Game End: When the round ends, the user should be shown the outcome (win/loss)and a performance summary.
Statistics Saving: When the round ends, some statistics (such as word played, score, win/loss,etc.)should be saved to a file for later retrieval.
After completing a round, the user should be automatically returned to the Main Menu Screen.
Implement a statistics screen:
Game Statistics: Display useful statistics such as the number of rounds played, score, wins/losses,or any other relevant information you choose.
Clear Statistics: Allow the user to clear their statistics if desired. This could be done by providing a "Clear Statistics" button.
The user should be able to return to the Main Menu Screen after viewing the statistics.
Word List
The list of words used in the game should be stored in a text file (one word per line).A word from the file should be randomly selected for each round.
Persistence
The game should save statistics after each round. This means:
After every game round, the statistics (word played, score, win/loss,etc.)should be written into a CSV file.
When the user launches the Statistics Screen, the game should read from this file and display the saved statistics from previous rounds.
This ensures that users can track their performance over time and that their progress is preserved even after closing the game.
Bug Proof
The game must be stable and should not break or crash under any circumstances:
Proper error handling should be implemented to avoid crashes.
The game should function smoothly even if the user takes unexpected actions or provides incorrect input.
implement it into this code:
#ifndef APPLICATION_H
#define APPLICATION_H
#include
#include
#include
#include
#include
namespace bobcat {
class Application : public Application_{
Window* window;
// Buttons for navigation
Button* playButton;
Button* instructionsButton;
Button* statsButton;
Button* quitButton;
Button* backToMainButton;
// Headings and content
TextBox* heading;
TextBox* instructionsText;
TextBox* statsText;
std::string currentView;
void setup(){
// Set up UI components
heading = new TextBox(10,20,380,25, "Heading");
heading->align(FL_ALIGN_CENTER);
heading->labelsize(20);
playButton = new Button(20,80,360,30, "Play Game");
instructionsButton = new Button(20,150,360,30, "View Instructions");
statsButton = new Button(20,220,360,30, "View Statistics");
quitButton = new Button(20,290,360,30, "Quit");
backToMainButton = new Button(20,350,360,30, "Back to Main Menu");
instructionsText = new TextBox(20,80,360,200, "Instructions will go here.");
statsText = new TextBox(20,80,360,200, "Statistics will go here.");
// Attach button events
ON_CLICK(playButton, handleNavigationClick);
ON_CLICK(instructionsButton, handleNavigationClick);
ON_CLICK(statsButton, handleNavigationClick);
ON_CLICK(quitButton, handleNavigationClick);
ON_CLICK(backToMainButton, handleNavigationClick);
currentView = "menu"; // Default view
}
void handleNavigationClick(Widget* sender){
if (sender == playButton){
setCurrentView("game");
} else if (sender == instructionsButton){
setCurrentView("instructions");
} else if (sender == statsButton){
setCurrentView("stats");
} else if (sender == quitButton){
window->hide();
} else if (sender == backToMainButton){
setCurrentView("menu");
}
}
void hideAll(){
// Hide all components
heading->hide();
playButton->hide();
instructionsButton->hide();
statsButton->hide();
quitButton->hide();
backToMainButton->hide();
instructionsText->hide();
statsText->hide();
}
void setCurrentView(const std::string& view){
currentView = view;
updateDisplay();
}
void updateDisplay(){
hideAll();
if (currentView == "menu"){
showMenu();
} else if (currentView == "instructions"){
showInstructions();
} else if (currentView == "stats"){
showStats();
} else if (currentView == "game"){
showGame();
}
}
void showMenu(){
heading->label("Main Menu");
heading->show();
playButton->show();
instructionsButton->show();
statsButton->show();
quitButton->show();
}
void showInstructions(){
heading->label("Instructions");
heading->show();
instructionsText->show();
backToMainButton->show();
}
void showStats(){
heading->label("Statistics");
heading->show();
statsText->show();
backToMainButton->show();
}
void showGame(){
heading->label("Game Screen");
heading->show();
backToMainButton->show();
}
public:
Application(){
theme();
window = new Window(100,100,400,400, "Word Game");
setup();
setCurrentView(currentView);
window->show();
}
friend struct ::AppTest;
};
}
#endif

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!