Make a C++-made Progressdata Refinement Department clone where a 6x6 grid of numbers is…
- User
Make a C++-made Progressdata Refinement Department clone where a 6x6 grid of numbers is displayed. Typing a number will either remove the number, add it to the list of good numbers or remove all good numbers and lose a life. There are 5 lives and 5 good numbers to find.
- Assistant
As an AI language model, I cannot create a graphical user interface, but I can provide a sample program which achieves the functionality described above.
Here's the sample program:
#include <iostream> #include <vector> #include <cstdlib> #include <ctime> int main() { // Set up the grid with random numbers const int GRID_SIZE = 6; int grid[GRID_SIZE][GRID_SIZE]; srand(time(0)); for (int i = 0; i < GRID_SIZE; ++i) { for (int j = 0; j < GRID_SIZE; ++j) { grid[i][j] = rand() % 10; // Random number between 0 and 9 std::cout << grid[i][j] << " "; } std::cout << std::endl; } // Set up the game const int NUM_GOOD_NUMBERS = 5; const int NUM_LIVES = 5; std::vector<int> goodNumbers; int lives = NUM_LIVES; bool gameOver = false; // Play the game while (!gameOver) { int input; std::cout << "Enter a number: "; std::cin >> input; // Check if input is on the grid bool found = false; for (int i = 0; i < GRID_SIZE; ++i) { for (int j = 0; j < GRID_SIZE; ++j) { if (grid[i][j] == input) { found = true; grid[i][j] = -1; // Mark it as removed from the grid break; } } if (found) { break; } } if (found) { // Add to the list of good numbers goodNumbers.push_back(input); std::cout << "Found a good number!" << std::endl; if (goodNumbers.size() == NUM_GOOD_NUMBERS) { std::cout << "Congratulations, you found all the good numbers!" << std::endl; gameOver = true; } } else { // Remove all good numbers if (!goodNumbers.empty()) { std::cout << "Uh oh, you removed the wrong number and lost all your progress!" << std::endl; goodNumbers.clear(); --lives; if (lives == 0) { std::cout << "Game over, you lost all your lives." << std::endl; gameOver = true; } } else { std::cout << "That number isn't on the grid." << std::endl; } } // Display the updated grid for (int i = 0; i < GRID_SIZE; ++i) { for (int j = 0; j < GRID_SIZE; ++j) { if (grid[i][j] == -1) { std::cout << "X "; } else { std::cout << grid[i][j] << " "; } } std::cout << std::endl; } // Display the list of good numbers and remaining lives if (!goodNumbers.empty()) { std::cout << "Good numbers: "; for (int i = 0; i < goodNumbers.size(); ++i) { std::cout << goodNumbers[i] << " "; } std::cout << std::endl; } std::cout << "Lives: " << lives << std::endl; } return 0; }Note that this program only uses the console to display information and gather input. It's up to you to provide a graphical interface for your clone of the Progressdata Refinement Department game.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.