Question: I am a beginner for c++. We just started learning c++ last week and its my first week learning it. I need help on working

I am a beginner for c++. We just started learning c++ last week and its my first week learning it. I need help on working on lab assignment. Must be written in c++. I have attached the instructions and also it provides examples on how the game sudoku game board should look like and also attached a picture of the main.cpp file. Thanks

numbers read from file:

I am a beginner for c++. We just started learning c++ last

instructions and examples:

week and its my first week learning it. I need help onworking on lab assignment. Must be written in c++. I have attachedthe instructions and also it provides examples on how the game sudokugame board should look like and also attached a picture of themain.cpp file. Thanks numbers read from file: instructions and examples: C++ file:Main.cpp #include #include #include using namespace std; int main(){ // Initialize file

C++ file: Main.cpp

ifstream ins("gameBoard.txt"); // ... // Set up the round, etc // Other

#include #include #include

using namespace std;

int main(){

// Initialize file ifstream ins("gameBoard.txt");

// ... // Set up the round, etc // Other code ...

// Read in two numbers from the file int num1, num2; ins >> num1 >> num2; cout

// continue on with the program

// Just before the game ends, close the file ins.close();

return 0; }

gameBoard- Notepad File Edit Format View Help 334243241131132422324224 For this lab, you w implement a simple number game. The goal of the game is to fill in a 3x3 board with the numbers1- 4 (inclusive), but a number cannot appear next to itself in a row or column. The numbers are read from a file and presented to the user two at a time. The user can choose one of the numbers or pass. There are three passes allowed in the game; the user loses the game on the fourth pass. The game is won if the board is successfully filled with numbers. Program Specifications Your program should Show the user the board before each turn and when the game is over On each turn, display the two numbers the user can choose from. Let the user pick one of the numbers to place or pass If the user chooses a number, ask where the user wants to put it. Use 0-based indexing. If the user passes, and that is the fourth time the user passes, the game should imme- diately end. The user loses the game. . The game should end, and the playcr wins, if the entire board is filled with numbers . Each time the user placcs a nnber, you should validate the user's input. Do not allow the user to pick an invalid location (row/column out of range), pick a place that alrcady has a number, or put a number next to itself. For example, if the first row is 1,, 3, a valid move would be to put a 2 in the second spot. An invalid move would be to try to put a 1 or a 3 in the second spot, since the same number cannot appear next to itself. . You should also validate any menu choices the user gives. For instance, do not allow the user to choose a number to place that isn't one of the available options. You never have to validate that the user has given you the proper datatype, though you can easily by using something like if (cin >> num). If the input cannot be stored in num, this statement is false. Round 1 1 3 I I You got numbers 4, 2 Choose number (-1 to pass): 4 Enter row and column numbers: 1 0 Round 12 3 I I 4 I I You got numbers 4, 3 Choose number (-1 to pass): 4 Enter row and column numbers: 2 0 Value cannot be next to same value Enter row and column numbers: 11 Value cannot be next to same value Enter row and column numbers: 4 5 Invalid row or column Enter row and column numbers: 0-4 Invalid row or column Enter row and column numbers: 0 1 Round 3 3 4I 4 I You got numbers 2, 4 Choose number (-1 to pass): 2 Enter row and column numbers: 11 Choose number (-1 to pass): 4 Enter row and column numbers: 2 1 Round 8 1 31 4l 11 You got numbers 2, 2 Choose number (-1 to pass): 2 Enter row and column numbers: 2 2 You win!! 1 31 4l 11 I 41 21 3 1 3 41 21 E include #include #include 4 using namespace std; int main(){ 9 10 // Initialize file : ifstream ins( "gameBoard.txt"); 12 13 // Set up the round, etc // Other code 15 16 17 18 19 20 21 // Read in two numbers from the file int num1, num2; ins > num1 >> num2; cout

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 Databases Questions!