URGENT!! Need help finishing 2-dim array game code!

So I have the basic structure of the code down, but I don't know how to finish the code to display my string of words on the grid or how to set a time limit for each of the conditions, any help would be so appreciated! Here are the instructions for my code to follow:

Select a Theme and have 50 words associated with it
Words must have a common theme - your choice

Examples: Like Periodic Table Elements, or Sports teams, or Types of cars…
Have one Term describing category you picked. This is the FACE term…

Menu:
Start Button
New Game Button
Exit Game Button

Level of Play – Use selects at start of game
4 x 4 grid (Easy)
6 x 6 grid (Moderate)
8 X 8 grid (Difficult)

Speed of Play – At start of game, User selects time interval for clicked-on term-pair to display
1 seconds (Difficult)
3 seconds (Moderate)
5 seconds (Easy)

Populate Grid with Term
At start of game – program places the same face/theme term in all squares in the visible grid

If 4 x 4 grid, randomly pick 8 terms, place each image name twice in 2-Dim array.
If 6 x 6 grid, randomly pick 18 terns, place each image name twice in 2-Dim array.
If 8 x 8 grid, randomly pick 32 terms, place each image name twice in 2-Dim array.
The 2-Dim Array corresponds to grid on screen.

During the course of play, the face/theme term in the grid is replaced by a
corresponding array terms, when user selects a grid square

Game Play

1) User selects a FIRST square, the theme/face term in the grid square is replace with correspond stored term, from the 2-dim array

2) User selects a SECOND square, the term theme/face in the second grid square is replace with the corresponding stored term, from the 2-dim array

3) The computer compares the terms for the two selected squares.
If they are the same, the terms remain on the screen and can no longer be selected.

If they are different, the term remain the screen for 1, 3 or 5 seconds, depending on user selection at the beginning of the game. After that elapse time, those two grid terms are replaced with the face/theme term.

#include <iostream>
#include <string>
using namespace std;

int main()
{
string startgame;
cout << "New game:1" << endl;
cout << " Exit game:2" << endl;
cin >> startgame;

if (startgame == "2")
{
cout << "GAME OVER" << endl;
return 0;
}

else if ((startgame == "1"))
{
int size = 0;
string Difficulty;

cout << "Easy: 4x4" << endl;
cout << "Moderate 6x6" << endl;
cout << "Hard 8x8" << endl;
cin >> Difficulty;

if (Difficulty == "easy")
{
size = 4;
}

if (Difficulty == "moderate")
{
size = 6;
}

if (Difficulty == "hard")
{
size = 8;
}

string states[50] = { "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO," "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY" };

string answerboard[8][8];
string Displayboard[8][8];

for (int row = 0; row<size; row++)
{
cout << "-----------------------" << endl;
for (int col = 0; col<size; col++)
{
cout << Displayboard[row][col] << " | ";

}
cout << endl;
}

for (int i = 0; i<(size / size) / 2; i++)
{

}


}
system("pause");
return 0;

}
is this an assignment?
yes for my computer class
I'm sorry, we don't do assignments
keskiverto wrote:
Please note that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.


but I don't know how to finish the code to display my string of words on the grid
What have you tried so far?
Last edited on
I added a cout statement to display the states, but it's only displaying just 1 letter of the acronym, but not both letters :

cout << states[row] [col];



1
2
3
4
5
6
7
8
9
10
11
12
13
for (int row = 0; row<size; row++)
		{
			cout << "-----------------------" << endl;
			for (int col = 0; col<size; col++)
			{
				cout << Displayboard[row][col] << " | ";
				cout << states[row] [col];
			}
			cout << endl;
		}

		for (int i = 0; i<(size / size) / 2; i++)
		{
states is a 1-Dimensional array.
string states[50] = {...};

but you try to access it like a matrix
cout << states[row] [col];
what happens is that states[row] accesses the string in your array and
the [col] accesses a character from that string

I guess you want to print the names in 8x8 Format so you have to put your states in an 8x8 array or access the element states[row*8+col]
Topic archived. No new replies allowed.