Hello guys, I am trying to use a Grid that I manipulated in a function (which returns the grid itself) and I initialized my Grid function to a variable within the another function I am trying to use the Grid in. Dont know how to use it because the I think my variable ends my second function early because of the return statement.
void humanTurn(string posWord) {
while (true) {
// this is the variable I am talking about "boardSetup"; right below
Grid<char> actualBoard = boardSetup();
string trueWord;
int x = 0;
int y = 0;
string posWord = getLine("Enter word (RETURN when done): ");
if (posWord == "") {
// call computer turn function
return;
}
if (posWord.length() < 4) {
cout << "This is word is too short. Try again." << endl;
continue;
}
if (!englishWords.contains(posWord)) {
cout << "That is not word. Try again" << endl;
continue;
}
if (humanWords.contains(posWord)) {
cout << "This word has already been used Try again." << endl;
continue;
}
for (int i = 0; i <= 15; i++) {
y += 1;
if (y == 4) {
y -= 4;
x += 1;
}
for (int j = 0; j >= posWord.length(); j++) {
char l = actualBoard.get(x,y);
string init = charToString(l);
}
}
for (int i = 0; i <= 16; i++) {
standardCubes.add(STANDARD_CUBES[i]);
}
for (int i = 0; i <= 16; i++) {
int r = randomInteger(0,15);
string temp = standardCubes[r];
standardCubes[r] = standardCubes[i];
standardCubes[i] = temp;
}
drawBoard(4,4);
for (int i = 0; i <= 15; i++) {
static int x = 0;
static int y = 0;
int randomFac = randomInteger(0,5);
string cube = standardCubes[i];
char face = (cube[randomFac]);
actualBoard.set(x,y,face);
labelCube(x,y,face);
y += 1;
if (y == 4) {
y -= 4;
x += 1;
}